Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgvJY-0000f9-Bp for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Oct 2021 20:50:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgvJX-0000n5-9q for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Oct 2021 20:50:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgvJX-0000mw-2V for pgsql-bugs@lists.postgresql.org; Sat, 30 Oct 2021 20:50:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgvJV-0002OD-1G for pgsql-bugs@lists.postgresql.org; Sat, 30 Oct 2021 20:50:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 19UKomf6856858; Sat, 30 Oct 2021 16:50:48 -0400 From: Tom Lane To: =?UTF-8?Q?Juan_Jos=C3=A9_Santamar=C3=ADa_Flecha?= cc: egashira.yusuke@fujitsu.com, PostgreSQL mailing lists Subject: Re: BUG #17254: Crash with 0xC0000409 in pg_stat_statements when pg_stat_tmp\pgss_query_texts.stat exceeded 2GB. In-reply-to: References: <17254-a926c89dc03375c2@postgresql.org> <840436.1635611203@sss.pgh.pa.us> Comments: In-reply-to =?UTF-8?Q?Juan_Jos=C3=A9_Santamar=C3=ADa_Flecha?= message dated "Sat, 30 Oct 2021 20:31:05 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <856856.1635627048.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 30 Oct 2021 16:50:48 -0400 Message-ID: <856857.1635627048@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?UTF-8?Q?Juan_Jos=3DC3=3DA9_Santamar=3DC3=3DADa_Flecha?=3D writes: > On Sat, Oct 30, 2021 at 6:26 PM Tom Lane wrote: >> I think instead, we need to turn the subsequent one-off read() call int= o a >> loop that reads no more than INT_MAX bytes at a time. It'd be possible >> to restrict that to Windows, but probably no harm in doing it the same >> way everywhere. > Seems reasonable to me, can such a change be back-patched? Don't see why not. >> A different line of thought is that maybe we shouldn't be letting the >> file get so big in the first place. Letting every backend have its >> own copy of a multi-gigabyte stats file is going to be problematic, >> and not only on Windows. It looks like the existing logic just conside= rs >> the number of hash table entries, not their size ... should we rearrang= e >> things to keep a running count of the space used? > +1. There should be a mechanism to limit the effective memory size. This, on the other hand, would likely be something for HEAD only. But now that we've seen a field complaint, it seems like a good thing to pursue. regards, tom lane