Re: Online checksums verification in the backend
Julien Rouhaud <rjuju123@gmail.com>
From: Julien Rouhaud <rjuju123@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Michael Paquier <michael@paquier.xyz>,
Justin Pryzby <pryzby@telsasoft.com>, Masahiko Sawada <masahiko.sawada@2ndquadrant.com>,
Robert Haas <robertmhaas@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Masahiko Sawada <sawada.mshk@gmail.com>
Date: 2020-10-30T03:58:13Z
Lists: pgsql-hackers
On Fri, Oct 30, 2020 at 10:58 AM Andres Freund <andres@anarazel.de> wrote: > > Hi, > > On 2020-10-30 10:01:08 +0800, Julien Rouhaud wrote: > > On Fri, Oct 30, 2020 at 2:17 AM Andres Freund <andres@anarazel.de> wrote: > > > The code does IO while holding the buffer mapping lock. That seems > > > *entirely* unacceptable to me. That basically locks 1/128 of shared > > > buffers against concurrent mapping changes, while reading data that is > > > likely not to be on disk? Seriously? > > > > The initial implementation had a different approach, reading the buffer once > > without holding the buffer mapping lock (which could lead to some false > > positive in some unlikely scenario), and only if a corruption is detected the > > read is done once again *while holding the buffer mapping lock* to ensure it's > > not a false positive. Some benchmarking showed that the performance was worse, > > so we dropped that optimisation. Should we go back to something like that or > > do you have a better way to ensure a consistent read of a buffer which isn't in > > shared buffers? > > I suspect that you're gonna need something quite different than what the > function is doing right now. Not because such a method will be faster in > isolation, but because there's a chance to have it correct and not have > a significant performance impact onto the rest of the system. > > I've not thought about it in detail yet. Is suspect you'll need to > ensure there is a valid entry in the buffer mapping table for the buffer > you're processing. By virtue of setting BM_IO_IN_PROGRESS on that entry > you're going to prevent concurrent IO from starting until your part is > done. So I'm assuming that the previous optimization to avoid almost every time doing an IO while holding a buffer mapping lock isn't an option? In that case, I don't see any other option than reverting the patch and discussing a new approach.
Commits
-
Revert pg_relation_check_pages()
- e152506adef4 14.0 landed
-
Fix incorrect placement of pfree() in pg_relation_check_pages()
- 60a51c6b3296 14.0 landed
-
Add pg_relation_check_pages() to check on-disk pages of a relation
- f2b883969557 14.0 landed
-
Add CheckBuffer() to check on-disk pages without shared buffer loading
- c780a7a90a8e 14.0 landed
-
Extend amcheck to check heap pages.
- 866e24d47db1 14.0 cited