Skip to content

Commit 104e878

Browse files
committed
Account of primary coming up in the middle of a failover
1 parent b39d479 commit 104e878

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pkg/flypg/zombie.go

+4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ func ZombieDiagnosis(myHostname string, total int, inactive int, active int, con
7979
// Calculate our references
8080
myCount := total - inactive - totalConflicts
8181

82+
// We have to fence the primary in case the active cluster is in the middle of a failover.
8283
if myCount >= quorum {
84+
if totalConflicts > 0 {
85+
return "", ErrZombieDiagnosisUndecided
86+
}
8387
return myHostname, nil
8488
}
8589

pkg/flypg/zombie_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ func TestZombieDiagnosis(t *testing.T) {
157157
}
158158

159159
primary, err := ZombieDiagnosis(hostname, total, inactive, active, conflictMap)
160-
if err != nil {
160+
if !errors.Is(err, ErrZombieDiagnosisUndecided) {
161161
t.Fatal(err)
162162
}
163163

164-
if primary != hostname {
164+
if primary != "" {
165165
t.Fatalf("expected %s, got %q", hostname, primary)
166166
}
167167
})

0 commit comments

Comments
 (0)