Re: [PATCH] Btree BackwardScan race condition on Standby during VACUUM
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Michail Nikolaev <michail.nikolaev@gmail.com>
Cc: "Andrey M. Borodin" <x4mmm@yandex-team.ru>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2020-03-28T01:45:18Z
Lists: pgsql-hackers
On Fri, Mar 27, 2020 at 8:58 AM Michail Nikolaev <michail.nikolaev@gmail.com> wrote: > I have spent some time trying to find any possible race condition > between btree_xlog_split and _bt_walk_left… But I can’t find any. > Also, I have tried to cause any issue by putting pg_sleep put into > btree_xlog_split (between releasing and taking of locks) but without > any luck. I pushed a commit that tries to clear up some of the details around how locking works during page splits. See commit 9945ad6e. > I agree it is better to keep the same locking logic for primary and > standby in general. But it is a possible scope of another patch. It seems useful, but only up to a point. We don't need to hold locks across related atomic operations (i.e. across each phase of a page split or page deletion). In particular, the lock coupling across page levels that we perform on the primary when ascending the tree following a page split doesn't need to occur on standbys. I added something about this to the nbtree README in commit 9f83468b353. I'm not surprised that you didn't find any problems in btree_xlog_split(). It is already conservative about locking the sibling/child pages. It could hardly be more conservative (though see the code and comments at the end of btree_xlog_split(), which mention locking and backwards scans directly). -- Peter Geoghegan
Commits
-
Fix replica backward scan race condition.
- 9a9db08ae462 14.0 landed
-
Justify nbtree page split locking in code comment.
- 9945ad6e9040 13.0 cited
-
Remove unneeded "pin scan" nbtree VACUUM code.
- 9f83468b3536 13.0 cited
-
Compute XID horizon for page level index vacuum on primary.
- 558a9165e081 12.0 cited
-
Make heap TID a tiebreaker nbtree index column.
- dd299df8189b 12.0 cited