9
9
gosql "database/sql"
10
10
"fmt"
11
11
"strings"
12
- "sync"
13
12
"sync/atomic"
14
13
"time"
15
14
@@ -935,7 +934,7 @@ func (this *Applier) CreateAtomicCutOverSentryTable() error {
935
934
}
936
935
937
936
// 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 {
939
938
tx , err := this .db .Begin ()
940
939
if err != nil {
941
940
tableLocked <- err
@@ -946,6 +945,7 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
946
945
tableLocked <- fmt .Errorf ("Unexpected error in AtomicCutOverMagicLock(), injected to release blocking channel reads" )
947
946
tableUnlocked <- fmt .Errorf ("Unexpected error in AtomicCutOverMagicLock(), injected to release blocking channel reads" )
948
947
tx .Rollback ()
948
+ this .DropAtomicCutOverSentryTableIfExists ()
949
949
}()
950
950
951
951
var sessionId int64
@@ -1014,12 +1014,10 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
1014
1014
sql .EscapeName (this .migrationContext .GetOldTableName ()),
1015
1015
)
1016
1016
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
+ }
1023
1021
1024
1022
// Tables still locked
1025
1023
this .migrationContext .Log .Infof ("Releasing lock from %s.%s, %s.%s" ,
0 commit comments