Re: autovacuum truncate exclusive lock round two

Jan Wieck <janwieck@yahoo.com>

From: Jan Wieck <JanWieck@Yahoo.com>
To: Amit Kapila <amit.kapila@huawei.com>
Cc: 'Stephen Frost' <sfrost@snowman.net>, 'PostgreSQL Development' <pgsql-hackers@postgresql.org>
Date: 2012-10-26T13:30:56Z
Lists: pgsql-hackers
On 10/26/2012 6:35 AM, Amit Kapila wrote:
> On Friday, October 26, 2012 11:50 AM Jan Wieck wrote:
>> On 10/26/2012 1:29 AM, Amit Kapila wrote:
>> >    One other way could be to check after every few pages for a
>> conflicting
>> > lock request.
>>
>> How is this any different from what my patch does?
>    The difference is that in the patch it checks for waiters by using 2
> parameters autovacuum_truncate_lock_check and blkno%32 and what I
>    had mentioned was to check only based on blkno.
>    Will it effect too much if we directly check for waiters after every 32
> (any feasible number) blocks?

The blkno%32 is there to not do the gettimeofday() call too often. But 
relying on the blkno alone is IMHO not a good idea. It had to be a 
number small enough so that even on a busy system and when the pages 
have to be read from disk, vacuum checks and releases the lock quickly. 
But large enough so that it doesn't create a significant amount of 
spinlock calls in the lmgr. We would end up with another parameter, 
number of blocks, that is a lot harder to estimate a good value for.


Jan

-- 
Anyone who trades liberty for security deserves neither
liberty nor security. -- Benjamin Franklin