Re: Race condition in SyncRepGetSyncStandbysPriority
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>,
masahiko.sawada@2ndquadrant.com, pgsql-hackers@lists.postgresql.org
Date: 2020-04-16T18:00:23Z
Lists: pgsql-hackers
Fujii Masao <masao.fujii@oss.nttdata.com> writes: > On 2020/04/14 22:52, Tom Lane wrote: >> *Yes it does*. The existing code can deliver entirely broken results >> if some walsender exits between where we examine the priorities and >> where we fetch the WAL pointers. > IMO that the broken results can be delivered when walsender marked > as sync exits *and* new walsender comes at that moment. If this new > walsender uses the WalSnd slot that the exited walsender used, > SyncRepGetOldestSyncRecPtr() wronly calculates the oldest lsn based > on this new walsender (i.e., different walsender from one marked as sync). Right, exactly, sorry that I was not more specific. > BTW, since the patch changes the API of SyncRepGetSyncStandbys(), > it should not be back-patched to avoid ABI break. Right? Anything that is using that is just as broken as the core code is, for the same reasons, so I don't have a problem with changing its API. Maybe we should rename it while we're at it, just to make it clear that we are breaking any external callers. (If there are any, which seems somewhat unlikely.) The only concession to ABI that I had in mind was to not re-order the fields of WalSnd in the back branches. regards, tom lane
Commits
-
Fix race conditions in synchronous standby management.
- c65c1aa82105 9.6.18 landed
- f332241a60aa 13.0 landed
- b3fa6d016d82 11.8 landed
- 63ecdaf758c5 10.13 landed
- 00ef5d52c577 12.3 landed
-
When WalSndCaughtUp, sleep only in WalSndWaitForWal().
- 421685812290 13.0 cited