-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resume from exact position and truncate the rest
The new logic finds the WAL segment file that contains the given message from the metadata and truncates upto the that position. According to the implementation of streamRotateFile, the message could be anywhere between pg_walfile_name(metadata->lsn) ... latest. Consider the following scenario where we have 4 WAL segment files: 000000010000000000000000.json 000000010000000000000001.json 000000010000000000000002.json 000000010000000000000003.json <-- latest When receive a message with LSN 0/144BEE0, the search starts from the corresponding WAL segment 000000010000000000000001.json and goes upto 000000010000000000000003.json(latest). Assume that we found the message in 000000010000000000000002.json, we need to truncate the file upto the message position and remove(renaming for debugging) all the files after that and make that file as the latest file. If we couldn't find the message in any of the files, it means that the message is not yet streamed and we can keep writing to the latest file. Signed-off-by: Arunprasad Rajkumar <[email protected]>
- Loading branch information
Showing
2 changed files
with
283 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters