Skip to content

Commit 3b21f4d

Browse files
committed
Close remaining DB connections
1 parent a1473df commit 3b21f4d

4 files changed

Lines changed: 17 additions & 0 deletions

File tree

go/logic/applier.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ func (this *Applier) WriteChangelogState(value string) (string, error) {
291291
}
292292

293293
func (this *Applier) FinalCleanup() {
294+
this.db.Close()
295+
this.singletonDB.Close()
294296
this.finishedMigrating = true
295297
}
296298

go/logic/migrator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,7 @@ func (this *Migrator) finalCleanup() error {
12241224

12251225
this.finishedMigrating = true
12261226
this.applier.FinalCleanup()
1227+
this.eventsStreamer.FinalCleanup()
12271228

12281229
return nil
12291230
}

go/logic/streamer.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,14 @@ func (this *EventsStreamer) StreamEvents(canStopStreaming func() bool) error {
192192
var successiveFailures int64
193193
var lastAppliedRowsEventHint mysql.BinlogCoordinates
194194
for {
195+
if canStopStreaming() {
196+
return nil
197+
}
195198
if err := this.binlogReader.StreamEvents(canStopStreaming, this.eventsChannel); err != nil {
199+
if canStopStreaming() {
200+
return nil
201+
}
202+
196203
log.Infof("StreamEvents encountered unexpected error: %+v", err)
197204
this.migrationContext.MarkPointOfInterest()
198205
time.Sleep(ReconnectStreamerSleepSeconds * time.Second)
@@ -223,3 +230,8 @@ func (this *EventsStreamer) Close() (err error) {
223230
log.Infof("Closed streamer connection. err=%+v", err)
224231
return err
225232
}
233+
234+
func (this *EventsStreamer) FinalCleanup() {
235+
this.db.Close()
236+
return
237+
}

go/mysql/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ func GetReplicationLag(connectionConfig *ConnectionConfig) (replicationLag time.
5151
replicationLag = time.Duration(secondsBehindMaster.Int64) * time.Second
5252
return nil
5353
})
54+
55+
db.Close()
5456
return replicationLag, err
5557
}
5658

0 commit comments

Comments
 (0)