Skip to content

Commit

Permalink
Handle unknown reasons why a db could be invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrks committed Feb 29, 2024
1 parent 0cc2656 commit 33d5116
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,12 @@ func (d *invalidDatabaseConfigs) addInvalidDatabase(ctx context.Context, dbname
base.SyncGatewayStats.GlobalStats.ConfigStat.DatabaseBucketMismatches.Add(1)
logMessage += " Mismatched buckets (config bucket: %q, actual bucket: %q)"
logArgs = append(logArgs, base.MD(d.dbNames[dbname].configBucketName), base.MD(d.dbNames[dbname].persistedBucketName))
} else if isRegistryDbConfigVersionInvalid(cnf.Version) {
} else if cnf.Version == invalidDatabaseConflictingCollectionsVersion {
base.SyncGatewayStats.GlobalStats.ConfigStat.DatabaseCollectionCollisions.Add(1)
logMessage += " Conflicting collections detected"
} else {
// Nothing is expected to hit this case, but we might add more invalid sentinel values and forget to update this code.
logMessage += "Invalid config with no known cause."
}

// if we get here we already have the db logged as an invalid config, so now we need to work out iof we should log for it now
Expand Down
2 changes: 2 additions & 0 deletions rest/config_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ type GatewayRegistry struct {

const GatewayRegistryVersion = "1.0"

// A set of special sentinel values to store as database versions.
// NOTE: Update addInvalidDatabase and isRegistryDbConfigVersionInvalid if you add more.
const (
// deletedDatabaseVersion represents an entry for an in-progress delete
deletedDatabaseVersion = "0-0"
Expand Down

0 comments on commit 33d5116

Please sign in to comment.