Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fRg9h-0002LK-UL for pgsql-bugs@arkaria.postgresql.org; Sat, 09 Jun 2018 15:51:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fRg9e-0000Uf-03 for pgsql-bugs@arkaria.postgresql.org; Sat, 09 Jun 2018 15:51:49 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fRg9d-0000UW-Lt for pgsql-bugs@lists.postgresql.org; Sat, 09 Jun 2018 15:51:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fRg9W-0006Cg-SP for pgsql-bugs@lists.postgresql.org; Sat, 09 Jun 2018 15:51:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w59FpbiG018768; Sat, 9 Jun 2018 11:51:37 -0400 From: Tom Lane To: Thomas Munro cc: Frits Jalvingh , Dilip Kumar , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15225: [XX000] ERROR: invalid DSA memory alloc request size 1073741824 / Where: parallel worker In-reply-to: References: <152802081668.26724.16985037679312485972@wrigleys.postgresql.org> Comments: In-reply-to Thomas Munro message dated "Sat, 09 Jun 2018 17:06:05 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18766.1528559497.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 09 Jun 2018 11:51:37 -0400 Message-ID: <18767.1528559497@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro writes: > Here is a tidier version that I'd like to commit before beta2, if > there are no objections. I've added this to the PostgreSQL 11 open > items page. That looks fine as far as it goes. But I noticed that the code that actually resizes the hashtable looks like /* Double the size of the bucket array. */ pstate->nbuckets *=3D 2; size =3D pstate->nbuckets * sizeof(dsa_pointer_atomic); hashtable->batches[0].shared->size +=3D size / 2; dsa_free(hashtable->area, hashtable->batches[0].shared->bu= ckets); hashtable->batches[0].shared->buckets =3D dsa_allocate(hashtable->area, size); buckets =3D (dsa_pointer_atomic *) dsa_get_address(hashtable->area, hashtable->batches[0].shared->buckets)= ; for (i =3D 0; i < pstate->nbuckets; ++i) dsa_pointer_atomic_init(&buckets[i], InvalidDsaPointer= ); with no apparent provision for failure of the realloc. So the first question is does the query actually fail cleanly if dsa_allocate gets an OOM, and the second is whether we really want to fail the query in such a case, rather than plow ahead with the existing bucket array. BTW, that method of updating shared->size would do credit to Rube Goldberg. Wouldn't this: hashtable->batches[0].shared->size =3D size; be both faster and less confusing? regards, tom lane