Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2.0 backport] CBG-4163 log the source of metadata ID #7071

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions rest/config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,23 +764,25 @@ func (b *bootstrapContext) computeMetadataID(ctx context.Context, registry *Gate
standardMetadataID := b.standardMetadataID(config.Name)

// If there's already a metadataID assigned to this database in the registry (including other config groups), use that
defaultMetadataIDInUse := false
defaultMetadataIDDb := ""
for _, cg := range registry.ConfigGroups {
for dbName, db := range cg.Databases {
if dbName == config.Name {
base.InfofCtx(ctx, base.KeyConfig, "Using metadata ID=%q from registry for db %q", base.MD(db.MetadataID), base.MD(dbName))
return db.MetadataID
}
if db.MetadataID == defaultMetadataID {
defaultMetadataIDInUse = true
// do not return standardMetadataID here in case there was a different metadata ID assigned to this database
defaultMetadataIDDb = config.Name
}
}
}

// If the default metadata ID is already in use in the registry by a different database, use standard ID.
if defaultMetadataIDInUse {
if defaultMetadataIDDb != "" {
base.InfofCtx(ctx, base.KeyConfig, "Using metadata ID %q for db %q since the default metadata ID is already in use by db %q", base.MD(standardMetadataID), base.MD(config.Name), base.MD(defaultMetadataIDDb))
return standardMetadataID
}

// If the database config doesn't include _default._default, use standard ID
if config.Scopes != nil {
defaultFound := false
Expand All @@ -792,6 +794,7 @@ func (b *bootstrapContext) computeMetadataID(ctx context.Context, registry *Gate
}
}
if !defaultFound {
base.InfofCtx(ctx, base.KeyConfig, "Using metadata ID %q for db %q since _default._default collection is not a collection targeted by this db", base.MD(standardMetadataID), base.MD(config.Name))
return standardMetadataID
}
}
Expand All @@ -806,11 +809,12 @@ func (b *bootstrapContext) computeMetadataID(ctx context.Context, registry *Gate
}

if exists && syncInfo.MetadataID != defaultMetadataID {
base.InfofCtx(ctx, base.KeyConfig, "Using metadata ID %q for db %q because db uses the default collection, and _sync:syncInfo in the default collection specifies the non-default metadata ID %q", base.MD(standardMetadataID), base.MD(config.Name), base.MD(syncInfo.MetadataID))
return standardMetadataID
}

base.InfofCtx(ctx, base.KeyConfig, "Using default metadata ID %q for db %q", base.MD(defaultMetadataID), base.MD(config.Name))
return defaultMetadataID

}

// standardMetadataID returns either the dbName or a base64 encoded SHA256 hash of the dbName, whichever is shorter.
Expand Down
Loading