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 1mgrC7-0008J5-DQ for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Oct 2021 16:26:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgrC4-0007aX-Nr for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Oct 2021 16:26:56 +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 1mgrC4-0007Yk-GV for pgsql-bugs@lists.postgresql.org; Sat, 30 Oct 2021 16:26:56 +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 1mgrBx-0008Pj-Cq for pgsql-bugs@lists.postgresql.org; Sat, 30 Oct 2021 16:26:55 +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 19UGQhsw840437; Sat, 30 Oct 2021 12:26:43 -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> Comments: In-reply-to =?UTF-8?Q?Juan_Jos=C3=A9_Santamar=C3=ADa_Flecha?= message dated "Sat, 30 Oct 2021 10:27:29 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <840435.1635611203.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 30 Oct 2021 12:26:43 -0400 Message-ID: <840436.1635611203@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: > Now, with 100% more patch attached. That seems like a pretty poor solution. It will cause pg_stat_statements to fail altogether as soon as the stats file exceeds 1GB. (Admittedly, failing is better than crashing, but not by that much.) Worse, it causes that to happen on EVERY platform, not only Windows where the problem is. I think instead, we need to turn the subsequent one-off read() call into 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. 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 considers the number of hash table entries, not their size ... should we rearrange things to keep a running count of the space used? regards, tom lane