Hi, On 2026-03-31 18:05:46 -0400, Andres Freund wrote: > On 2026-03-31 19:02:33 +0300, Yura Sokolov wrote: > > 27.03.2026 23:00, Andres Freund wrote: > > > On 2026-03-25 18:35:55 -0400, Andres Freund wrote: > > >> Running it through valgrind and then will work on reading through one > > >> more > > >> time and pushing them. > > > > > > And done. > > > > > > Phew, this project took way longer than I'd though it'd take. > > > > In addition to bug with BM_IO_ERROR [1] , I found race condition in > > PinBuffer in this lines of code: > > > > if (unlikely(skip_if_not_valid && !(old_buf_state & BM_VALID))) > > return false; > > > > /* > > * We're not allowed to increase the refcount while the buffer > > * header spinlock is held. Wait for the lock to be released. > > */ > > if (old_buf_state & BM_LOCKED) > > old_buf_state = WaitBufHdrUnlocked(buf); > > > > While we waited for buffer header for being unlocked, it may become > > invalid, isn't it? > > Therefore, check related to skip_if_not_valid have to happen after waiting. > > Yea, that does seem wrong. Not sure how it ended up that way. > > I think it may be better to add a continue after the WaitBufHdrUnlocked(), so > that we restart the loop, rather than moving the skip_if_not_valid check.
Done that way. Thanks for finding & reporting this, well spotted! Greetings, Andres
