Re: "Allow usage of huge maintenance_work_mem for GIN build" patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: "Allow usage of huge maintenance_work_mem for GIN build" patch
Date: 2016-05-30 16:30:23
Message-ID: 12419.1464625823@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Teodor Sigaev <teodor(at)sigaev(dot)ru> writes:
>> Are you sure this is safe, Teodor? I don't have time to study the
>> patch in detail, but offhand I think that it might have been better to
>> make allocatedMemory of type int64, just like the tuplesort.c memory
>> accounting variables are post-MaxAllocHuge. It's not obvious to me
>> that this variable isn't allowed to occasionally become negative, just
>> like in tuplesort.c. It looks like that *might* be true -- ginbulk.c
>> may let allocatedMemory go negative for a period, which would now be
>> broken.

> It could not be negative - subtruction is doing only around repalloc call, in
> all other places it only grows.

As long as we're certain of that, Size seems like the appropriate field
type. But I wonder if it'd be worth adding an assert to the subtraction
steps, ie

Assert(accum->allocatedMemory >= delta);
accum->allocatedMemory -= delta;

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-05-30 16:37:49 Re: IPv6 link-local addresses and init data type
Previous Message David Fetter 2016-05-30 15:38:23 PostgreSQL Weekly News Survey