Skip to content

Commit b7db8c6

Browse files
authored
Merge pull request #1180 from lmtwga/master
2 parents 7320fda + bea5323 commit b7db8c6

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

go/logic/applier.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
gosql "database/sql"
1010
"fmt"
1111
"strings"
12-
"sync"
1312
"sync/atomic"
1413
"time"
1514

@@ -935,7 +934,7 @@ func (this *Applier) CreateAtomicCutOverSentryTable() error {
935934
}
936935

937936
// AtomicCutOverMagicLock
938-
func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocked chan<- error, okToUnlockTable <-chan bool, tableUnlocked chan<- error, dropCutOverSentryTableOnce *sync.Once) error {
937+
func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocked chan<- error, okToUnlockTable <-chan bool, tableUnlocked chan<- error) error {
939938
tx, err := this.db.Begin()
940939
if err != nil {
941940
tableLocked <- err
@@ -946,6 +945,7 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
946945
tableLocked <- fmt.Errorf("Unexpected error in AtomicCutOverMagicLock(), injected to release blocking channel reads")
947946
tableUnlocked <- fmt.Errorf("Unexpected error in AtomicCutOverMagicLock(), injected to release blocking channel reads")
948947
tx.Rollback()
948+
this.DropAtomicCutOverSentryTableIfExists()
949949
}()
950950

951951
var sessionId int64
@@ -1014,12 +1014,10 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
10141014
sql.EscapeName(this.migrationContext.GetOldTableName()),
10151015
)
10161016

1017-
dropCutOverSentryTableOnce.Do(func() {
1018-
if _, err := tx.Exec(query); err != nil {
1019-
this.migrationContext.Log.Errore(err)
1020-
// We DO NOT return here because we must `UNLOCK TABLES`!
1021-
}
1022-
})
1017+
if _, err := tx.Exec(query); err != nil {
1018+
this.migrationContext.Log.Errore(err)
1019+
// We DO NOT return here because we must `UNLOCK TABLES`!
1020+
}
10231021

10241022
// Tables still locked
10251023
this.migrationContext.Log.Infof("Releasing lock from %s.%s, %s.%s",

go/logic/migrator.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"math"
1414
"os"
1515
"strings"
16-
"sync"
1716
"sync/atomic"
1817
"time"
1918

@@ -639,12 +638,8 @@ func (this *Migrator) atomicCutOver() (err error) {
639638
defer atomic.StoreInt64(&this.migrationContext.InCutOverCriticalSectionFlag, 0)
640639

641640
okToUnlockTable := make(chan bool, 4)
642-
var dropCutOverSentryTableOnce sync.Once
643641
defer func() {
644642
okToUnlockTable <- true
645-
dropCutOverSentryTableOnce.Do(func() {
646-
this.applier.DropAtomicCutOverSentryTableIfExists()
647-
})
648643
}()
649644

650645
atomic.StoreInt64(&this.migrationContext.AllEventsUpToLockProcessedInjectedFlag, 0)
@@ -653,7 +648,7 @@ func (this *Migrator) atomicCutOver() (err error) {
653648
tableLocked := make(chan error, 2)
654649
tableUnlocked := make(chan error, 2)
655650
go func() {
656-
if err := this.applier.AtomicCutOverMagicLock(lockOriginalSessionIdChan, tableLocked, okToUnlockTable, tableUnlocked, &dropCutOverSentryTableOnce); err != nil {
651+
if err := this.applier.AtomicCutOverMagicLock(lockOriginalSessionIdChan, tableLocked, okToUnlockTable, tableUnlocked); err != nil {
657652
this.migrationContext.Log.Errore(err)
658653
}
659654
}()

0 commit comments

Comments
 (0)