-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --until-binlog-last-modified-time
option to `wal-g-mysql binlog…
#1154
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,12 +184,12 @@ type binlogHandler interface { | |
handleBinlog(binlogPath string) error | ||
} | ||
|
||
func fetchLogs(folder storage.Folder, dstDir string, startTS time.Time, endTS time.Time, handler binlogHandler) error { | ||
func fetchLogs(folder storage.Folder, dstDir string, startTS, endTS, endBinlogTS time.Time, handler binlogHandler) error { | ||
logFolder := folder.GetSubFolder(BinlogPath) | ||
includeStart := true | ||
outer: | ||
for { | ||
logsToFetch, err := getLogsCoveringInterval(logFolder, startTS, includeStart) | ||
logsToFetch, err := getLogsCoveringInterval(logFolder, startTS, includeStart, endBinlogTS) | ||
includeStart = false | ||
if err != nil { | ||
return err | ||
|
@@ -261,7 +261,7 @@ func getBinlogSinceTS(folder storage.Folder, backup internal.Backup) (time.Time, | |
} | ||
|
||
// getLogsCoveringInterval lists the operation logs that cover the interval | ||
func getLogsCoveringInterval(folder storage.Folder, start time.Time, includeStart bool) ([]storage.Object, error) { | ||
func getLogsCoveringInterval(folder storage.Folder, start time.Time, includeStart bool, endBinlogTS time.Time) ([]storage.Object, error) { | ||
logFiles, _, err := folder.ListFolder() | ||
if err != nil { | ||
return nil, err | ||
|
@@ -271,6 +271,9 @@ func getLogsCoveringInterval(folder storage.Folder, start time.Time, includeStar | |
}) | ||
var logsToFetch []storage.Object | ||
for _, logFile := range logFiles { | ||
if logFile.GetLastModified().After(endBinlogTS) { | ||
continue // don't fetch binlogs from future | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shold not affect the final result, as mysqbinlog started as
and should not replay transactions happened after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This patch fixes following issue: Live MySQL cluster A constantly uploads binlogs. We are trying to restore new cluster (let's call it B) from S3 on some point in time, e.g. The root cause of this issue is simple: newly uploaded binlog file may contain transactions that happend before user-specified To prevent different GTID-sets we should:
This 2 rules guarantees that all restored clones will have same binlog files replayed and as a result - same GTID-sets. |
||
if start.Before(logFile.GetLastModified()) || includeStart && start.Equal(logFile.GetLastModified()) { | ||
logsToFetch = append(logsToFetch, logFile) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the difference between fetchUntilTS and fetchUntilBinlogLastModifiedTS ?
can we use fetchUntilTs instead of fetchUntilBinlogLastModifiedTS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I am introducing new should distinguish two timestamps:
fetchUntilTS
- is about time of individual transactionsfetchUntilBinlogLastModifiedTS
- is about time when binlog was createdThere are 2 properties:
fetchUntilTS < fetchUntilBinlogLastModifiedTS
- because transactions dumped to binlog before binlog upload--stop-datetime < fetchUntilBinlogLastModifiedTS
- it is new rule that fixes multi-host restores (check detailed explanation in another comment)