Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.

Commit 2ae122d

Browse files
rashiqBtara Truhandarien
authored andcommitted
Merge pull request github#1180 from lmtwga/master
1 parent 4f3a6b2 commit 2ae122d

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

go/logic/applier.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ package logic
88
import (
99
gosql "database/sql"
1010
"fmt"
11+
<<<<<<< HEAD
1112
"sync"
13+
=======
14+
>>>>>>> b7db8c6 (Merge pull request #1180 from lmtwga/master)
1215
"strings"
1316
"sync/atomic"
1417
"time"
@@ -885,7 +888,7 @@ func (this *Applier) CreateAtomicCutOverSentryTable() error {
885888
}
886889

887890
// AtomicCutOverMagicLock
888-
func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocked chan<- error, okToUnlockTable <-chan bool, tableUnlocked chan<- error, dropCutOverSentryTableOnce *sync.Once) error {
891+
func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocked chan<- error, okToUnlockTable <-chan bool, tableUnlocked chan<- error) error {
889892
tx, err := this.db.Begin()
890893
if err != nil {
891894
tableLocked <- err
@@ -896,6 +899,7 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
896899
tableLocked <- fmt.Errorf("Unexpected error in AtomicCutOverMagicLock(), injected to release blocking channel reads")
897900
tableUnlocked <- fmt.Errorf("Unexpected error in AtomicCutOverMagicLock(), injected to release blocking channel reads")
898901
tx.Rollback()
902+
this.DropAtomicCutOverSentryTableIfExists()
899903
}()
900904

901905
var sessionId int64
@@ -964,12 +968,10 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
964968
sql.EscapeName(this.migrationContext.GetOldTableName()),
965969
)
966970

967-
dropCutOverSentryTableOnce.Do(func() {
968-
if _, err := tx.Exec(query); err != nil {
969-
this.migrationContext.Log.Errore(err)
970-
// We DO NOT return here because we must `UNLOCK TABLES`!
971-
}
972-
})
971+
if _, err := tx.Exec(query); err != nil {
972+
this.migrationContext.Log.Errore(err)
973+
// We DO NOT return here because we must `UNLOCK TABLES`!
974+
}
973975

974976
// Tables still locked
975977
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
@@ -12,7 +12,6 @@ import (
1212
"math"
1313
"os"
1414
"strings"
15-
"sync"
1615
"sync/atomic"
1716
"time"
1817

@@ -650,12 +649,8 @@ func (this *Migrator) atomicCutOver() (err error) {
650649
defer atomic.StoreInt64(&this.migrationContext.InCutOverCriticalSectionFlag, 0)
651650

652651
okToUnlockTable := make(chan bool, 4)
653-
var dropCutOverSentryTableOnce sync.Once
654652
defer func() {
655653
okToUnlockTable <- true
656-
dropCutOverSentryTableOnce.Do(func() {
657-
this.applier.DropAtomicCutOverSentryTableIfExists()
658-
})
659654
}()
660655

661656
atomic.StoreInt64(&this.migrationContext.AllEventsUpToLockProcessedInjectedFlag, 0)
@@ -664,7 +659,7 @@ func (this *Migrator) atomicCutOver() (err error) {
664659
tableLocked := make(chan error, 2)
665660
tableUnlocked := make(chan error, 2)
666661
go func() {
667-
if err := this.applier.AtomicCutOverMagicLock(lockOriginalSessionIdChan, tableLocked, okToUnlockTable, tableUnlocked, &dropCutOverSentryTableOnce); err != nil {
662+
if err := this.applier.AtomicCutOverMagicLock(lockOriginalSessionIdChan, tableLocked, okToUnlockTable, tableUnlocked); err != nil {
668663
this.migrationContext.Log.Errore(err)
669664
}
670665
}()

0 commit comments

Comments
 (0)