Re: PITR promote bug: Checkpointer writes to older timeline
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: masao.fujii@oss.nttdata.com, soumyadeep2007@gmail.com, hlinnaka@iki.fi, pgsql-hackers@postgresql.org, jyih@vmware.com, kyeap@vmware.com
Date: 2021-03-14T08:59:59Z
Lists: pgsql-hackers
Attachments
- fix-pitr-2pc-v3.patch (text/x-diff) patch v3
On Thu, Mar 04, 2021 at 05:10:36PM +0900, Kyotaro Horiguchi wrote: > read_local_xlog_page is *designed* to maintain ThisTimeLineID. > Currently it doesn't seem utilized but I think it's sufficiently > reasonable that the function maintains ThisTimeLineID. I don't quite follow this line of thoughts. ThisTimeLineID is designed to remain 0 while recovery is running in most processes (at the close exception of a WAL sender with a cascading setup, physical or logical, of course), so why is there any business for read_local_xlog_page() to touch this field at all while in recovery to begin with? I equally find confusing that XLogReadDetermineTimeline() relies on a specific value of ThisTimeLineID in its own logic, while it clearly states that all its callers have to read the current active TLI beforehand. So I think that the existing logic is pretty weak, and that resetting the field is an incorrect approach? It seems to me that we had better not change ThisTimeLineID actively while in recovery in this code path and just let others do the job, like RecoveryInProgress() once recovery finishes, or GetStandbyFlushRecPtr() for a WAL sender. And finally, we should store the current TLI used for replay in a separate variable that gets passed down to the XLogReadDetermineTimeline() as argument. While going through it, I have simplified a bit the proposed TAP tests (thanks for replacing the sleep() call, Soumyadeep. This would have made the test slower for nothing on fast machines, and it would cause failures on very slow machines). The attached fixes the original issue for me, keeping all the records in their correct timeline. And I have not been able to break cascading setups. If it happens that such cases actually break, we have holes in our existing test coverage that should be improved. I cannot see anything fancy missing on this side, though. Any thoughts? -- Michael
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix timeline assignment in checkpoints with 2PC transactions
- 1ec7162a8d34 10.17 landed
- f1d550f188e2 11.12 landed
- 4b1dd9b1ea75 12.7 landed
- 6e5ce888ad1e 13.3 landed
- 595b9cba2ab0 14.0 landed