Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitae6d69a

Browse files
committed
Merge pull requestsorintlab#161 from sgotti/keeper_check_same_timeline
keeper: check for same timeline but different switchpoints.
2 parentsa3f1399 +cf21e5d commitae6d69a

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

‎cmd/keeper/keeper.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,31 @@ func (p *PostgresKeeper) isDifferentTimelineBranch(fPGState *cluster.PostgresSta
552552
log.Infof("followed instance timeline %d < than our timeline %d",fPGState.TimelineID,pgState.TimelineID)
553553
returntrue
554554
}
555+
556+
// if the timelines are the same check that also the switchpoints are the same.
555557
iffPGState.TimelineID==pgState.TimelineID {
556-
returnfalse
558+
ifpgState.TimelineID<=1 {
559+
// if timeline <= 1 then no timeline history file exists.
560+
returnfalse
561+
}
562+
ftlh:=fPGState.TimelinesHistory.GetTimelineHistory(pgState.TimelineID-1)
563+
tlh:=pgState.TimelinesHistory.GetTimelineHistory(pgState.TimelineID-1)
564+
ifftlh==nil||tlh==nil {
565+
// No timeline history to check
566+
returnfalse
567+
}
568+
ifftlh.SwitchPoint==tlh.SwitchPoint {
569+
returnfalse
570+
}
571+
log.Infof("followed instance timeline %d forked at a different xlog pos %d then our timeline (timeline %d at xlog pos %d)",fPGState.TimelineID,ftlh.SwitchPoint,pgState.TimelineID,tlh.SwitchPoint)
572+
returntrue
557573
}
558574

559575
// fPGState.TimelineID > pgState.TimelineID
560-
tlh:=fPGState.TimelinesHistory.GetTimelineHistory(pgState.TimelineID)
561-
iftlh!=nil {
562-
iftlh.SwitchPoint<pgState.XLogPos {
563-
log.Infof("followed instance timeline %d forked at xlog pos %d before our current state (timeline %d at xlog pos %d)",fPGState.TimelineID,tlh.SwitchPoint,pgState.TimelineID,pgState.XLogPos)
576+
ftlh:=fPGState.TimelinesHistory.GetTimelineHistory(pgState.TimelineID)
577+
ifftlh!=nil {
578+
ifftlh.SwitchPoint<pgState.XLogPos {
579+
log.Infof("followed instance timeline %d forked at xlog pos %d before our current state (timeline %d at xlog pos %d)",fPGState.TimelineID,ftlh.SwitchPoint,pgState.TimelineID,pgState.XLogPos)
564580
returntrue
565581
}
566582
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp