Skip to content

Commit

Permalink
Introduce new EXIST_IN_DB migration code
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Jul 5, 2022
1 parent 98f4752 commit f2399db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dbs/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ DBS migration status codes:
1=IN PROGRESS
2=COMPLETED
3=FAILED (will be retried)
4=EXIST_IN_DB
9=Terminally FAILED
status change:
0 -> 1
1 -> 2
1 -> 3
1 -> 4
1 -> 9
are only allowed changes for working through migration.
3 -> 1 is allowed for retrying and retry count +1.
Expand All @@ -63,6 +65,7 @@ const (
IN_PROGRESS
COMPLETED
FAILED
EXIST_IN_DB
TERM_FAILED = 9
)

Expand Down Expand Up @@ -497,6 +500,8 @@ func statusString(status int64) string {
s = "FAILED"
} else if status == TERM_FAILED {
s = "TERMINATED"
} else if status == EXIST_IN_DB {
s = "EXIST_IN_DB"
}
return s
}
Expand Down Expand Up @@ -610,6 +615,8 @@ func startMigrationRequest(rec MigrationRequest) ([]MigrationReport, error) {

// if no migration blocks found to process return immediately
if len(migBlocks) == 0 {
rec.MIGRATION_STATUS = EXIST_IN_DB
updateMigrationStatus(rec, EXIST_IN_DB)
msg = fmt.Sprintf("%s is already fulfilled, no blocks found for migration", mstr)
log.Println(msg)
return []MigrationReport{migrationReport(rec, msg, status, err)}, nil
Expand Down
9 changes: 6 additions & 3 deletions docs/MigrationServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ from underlying DB backend on periodic basis
- 2 migration request has successfully completed
- 3 migration request has failed, it will be retried according to DB
migration server settings (by default 3 times)
- 4 migration request is already exist in DB, i.e. the requested block or
dataset is already found in database
- 9 migration request termindated, this can happen in two scenarios
- migration request has been cancelled explicitly by user
- migration request failed N times and will no longer be retried
automatically
The migration request goes throught the followin cycle:
```
status change:
0 -> 1
1 -> 2
0 -> 1, request in progress
1 -> 2, request is completed successfully
1 -> 3, and if failed 3->1
1 -> 9
1 -> 4, if request is alaready in DB
1 -> 9, request is terminated
```

### Examples
Expand Down

0 comments on commit f2399db

Please sign in to comment.