Skip to content
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

prevent purge when there is only one binlog file #585

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cluster/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,5 @@ var clusterError = map[string]string{
"WARN0104": "Enforce replication mode strict but idempotent on server %s",
"WARN0105": "Force Binlog Purge is not yet available in multi master. Skipping",
"WARN0106": "Minimum number of connected replica(s) is not enough to initiate force purging. Minimum replicas: %d. Skipping",
"WARN0107": "Force Binlog Purge can not continue. Oldest binlog is still used by slaves: %s.%d. Skipping",
}
14 changes: 6 additions & 8 deletions cluster/srv_binlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,12 @@ func (server *ServerMonitor) JobBinlogPurgeMaster() {
lastfile := 0

//Accumulating newest binlog size and shifting to oldest
for totalSize < uint(cluster.Conf.ForceBinlogPurgeTotalSize*(1024*1024*1024)) {
for latestbinlog > 0 && totalSize < uint(cluster.Conf.ForceBinlogPurgeTotalSize*(1024*1024*1024)) {
filename := prefix + "." + fmt.Sprintf("%06d", latestbinlog)
if size, ok := server.BinaryLogFiles[filename]; ok {
//accumulating size
totalSize += size
lastfile = latestbinlog //last file based on total size
} else {
cluster.LogModulePrintf(cluster.Conf.Verbose, config.ConstLogModGeneral, LvlInfo, "Filename not found on %s: %s", server.URL, filename)
}
//Descending
latestbinlog--
Expand All @@ -255,8 +253,8 @@ func (server *ServerMonitor) JobBinlogPurgeMaster() {
for oldestbinlog <= lastfile {
//Halt and return if last binlogfile is same with slave master pos
if oldestbinlog == cluster.SlavesOldestMasterFile.Suffix {
if cluster.StateMachine.CurState.Search("WARN0105") == false {
cluster.StateMachine.AddState("WARN0105", state.State{ErrType: "WARNING", ErrDesc: clusterError["WARN0105"], ErrFrom: "CHECK", ServerUrl: server.URL})
if cluster.StateMachine.CurState.Search("WARN0107") == false {
cluster.StateMachine.AddState("WARN0107", state.State{ErrType: "WARNING", ErrDesc: fmt.Sprintf(clusterError["WARN0107"], cluster.SlavesOldestMasterFile.Prefix, cluster.SlavesOldestMasterFile.Suffix), ErrFrom: "CHECK", ServerUrl: server.URL})
}
return
}
Expand Down Expand Up @@ -439,7 +437,7 @@ func (server *ServerMonitor) CheckAndPurgeBinlogMaster() {
}
} else {
// cluster.LogModulePrintf(cluster.Conf.Verbose, config.ConstLogModGeneral, LvlErr, "Purging check")
if !server.IsPurgingBinlog() {
if !server.IsPurgingBinlog() && len(server.BinaryLogFiles) > 1 {
cluster.LogModulePrintf(cluster.Conf.Verbose, config.ConstLogModGeneral, LvlDbg, "MariaDB Version is not compatible for max_binlog_total_size, using manual purging")
go server.JobBinlogPurgeMaster()
}
Expand Down Expand Up @@ -467,9 +465,9 @@ func (server *ServerMonitor) CheckAndPurgeBinlogSlave() {
cluster.LogModulePrintf(cluster.Conf.Verbose, config.ConstLogModGeneral, LvlInfo, err.Error())
}
} else {
if !server.IsPurgingBinlog() {
if !server.IsPurgingBinlog() && len(server.BinaryLogFiles) > 1 {
cluster.LogModulePrintf(cluster.Conf.Verbose, config.ConstLogModGeneral, LvlDbg, "MariaDB Version is not compatible for max_binlog_total_size, using manual purging")
if cluster.StateMachine.CurState.Search("WARN0105") == false {
if cluster.StateMachine.CurState.Search("WARN0107") == false {
go server.JobBinlogPurgeSlave()
}
}
Expand Down