Skip to content

Commit

Permalink
Add solution to resolve stale QUEUED migration requests
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Sep 20, 2022
1 parent 58b1aab commit 4e2ecc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 8 additions & 1 deletion dbs/migration_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ func MigrationServer(interval, timeout int, ch <-chan bool) {
api.Params = params
time0 := time.Now()
atomic.AddUint64(&TotalMigrationRequests, 1)
api.ProcessMigration()
if r.MIGRATION_STATUS == QUEUED {
// asynchronously start migration request
// the StartMigrationRequest relies on MigrationAsyncTimeout (in sec)
// context timeout
go StartMigrationRequest(r)
} else {
api.ProcessMigration()
}
log.Printf("migration process %+v finished in %v", params, time.Since(time0))
}
}
Expand Down
5 changes: 2 additions & 3 deletions static/sql/migration_requests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ JOIN {{.Owner}}.MIGRATION_BLOCKS MB ON MB.MIGRATION_REQUEST_ID=MR.MIGRATION_REQU

{{if .Oldest}}
WHERE MR.MIGRATION_STATUS=0
or MR.MIGRATION_STATUS=1
or (MR.migration_status=3 and MR.retry_count=0 and MR.last_modification_date <= {{.Date1}})
or (MR.migration_status=3 and MR.retry_count=1 and MR.last_modification_date <= {{.Date2}})
or (MR.migration_status=3 and MR.retry_count=2 and MR.last_modification_date <= {{.Date3}})
--or (MR.migration_status=0 and MR.retry_count=0 and MR.last_modification_date <= {{.PendingDate}})
--or (MR.migration_status=1 and MR.retry_count=0 and MR.last_modification_date <= {{.ProgressDate}})
or MR.MIGRATION_STATUS=1
or (MR.migration_status=5 and MR.retry_count=0 and MR.last_modification_date <= {{.Date1}})
{{end}}

0 comments on commit 4e2ecc4

Please sign in to comment.