Skip to content

Commit

Permalink
internal/db: Check for schema version differences before/after updateV1
Browse files Browse the repository at this point in the history
Prior to updateFromV1, both the internal and external update count is
stored in one variable, so we need to check for version differences
between cluster members slightly differently. After the update, the
columns are split so we don't need to add the two values together.

Signed-off-by: Max Asnaashari <[email protected]>
  • Loading branch information
masnax committed Jun 17, 2024
1 parent 9a62449 commit 0c7efa1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions internal/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,27 @@ func (db *DB) waitUpgrade(bootstrap bool, ext extensions.Extensions) error {
return fmt.Errorf("Failed to update schema version when joining cluster: %w", err)
}

versionsInternal, versionsExternal, err := cluster.GetClusterMemberSchemaVersions(ctx, tx)
versionsInternal, versionsExternal, ranUpdateV1, err := cluster.GetClusterMemberSchemaVersions(ctx, tx)
if err != nil {
return fmt.Errorf("Failed to get other members' schema versions: %w", err)
}

otherNodesBehindInternal, err := checkSchemaVersion(schemaVersionInternal, versionsInternal)
if err != nil {
return err
}
var otherNodesBehindInternal, otherNodesBehindExternal bool
if !ranUpdateV1 {
otherNodesBehindInternal, err = checkSchemaVersion(schemaVersionInternal+schemaVersionExternal, versionsInternal)
if err != nil {
return err
}
} else {
otherNodesBehindInternal, err = checkSchemaVersion(schemaVersionInternal, versionsInternal)
if err != nil {
return err
}

otherNodesBehindExternal, err := checkSchemaVersion(schemaVersionExternal, versionsExternal)
if err != nil {
return err
otherNodesBehindExternal, err = checkSchemaVersion(schemaVersionExternal, versionsExternal)
if err != nil {
return err
}
}

// Wait until after considering both internal and external schema versions to determine if we should wait for other nodes.
Expand Down

0 comments on commit 0c7efa1

Please sign in to comment.