Hi,

On 2026-08-11 19:15:48 +0100, Alexandre Felipe wrote:
> While reviewing another thread [1], I noticed a metion to lock duration,
> and I think there is room to improve the current implementation on
> InvalidateBuffer
> and InvalidateVictimBuffer, that thread is already a fork of something else,
> but I think this has its own merit.
> 
> In my (current) understanding partition LWLock guards a fraction of the
> hash table
> entries, and the buffer header lock as the name suggests guards the buffer
> descriptor.

> I think holding the Buffer header lock is not a problem,
> as contention would require someone else accessing precisely that buffer,
> holding the partition lock is more critical, as it may contend on thousands
> of
> distinct buffers.
> 
> This patch minimises the partition time, and keep the buffer header
> guarding
> the largest portion of the function body.

You absolutely, definitely, never, ever ever may hold a spinlock over
something even remotely as complicated like an lwlock or a hashtable
delete. NEVER.

And without that the patch is completely unsafe.

Greetings,

Andres Freund


Reply via email to