Re: "Allow usage of huge maintenance_work_mem for GIN build" patch - Mailing list pgsql-hackers

From Tom Lane
Subject Re: "Allow usage of huge maintenance_work_mem for GIN build" patch
Date
Msg-id 12419.1464625823@sss.pgh.pa.us
Whole thread Raw
In response to Re: "Allow usage of huge maintenance_work_mem for GIN build" patch  (Teodor Sigaev <teodor@sigaev.ru>)
List pgsql-hackers
Teodor Sigaev <teodor@sigaev.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



pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: PostgreSQL Weekly News Survey
Next
From: Tom Lane
Date:
Subject: Re: IPv6 link-local addresses and init data type