Skip to content

Commit ae73178

Browse files
authored
[3.1.10 backport] CBG-4162 log the source of metadata ID (#7072)
1 parent fc5b107 commit ae73178

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

rest/config_manager.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -763,23 +763,25 @@ func (b *bootstrapContext) computeMetadataID(ctx context.Context, registry *Gate
763763
standardMetadataID := b.standardMetadataID(config.Name)
764764

765765
// If there's already a metadataID assigned to this database in the registry (including other config groups), use that
766-
defaultMetadataIDInUse := false
766+
defaultMetadataIDDb := ""
767767
for _, cg := range registry.ConfigGroups {
768768
for dbName, db := range cg.Databases {
769769
if dbName == config.Name {
770+
base.InfofCtx(ctx, base.KeyConfig, "Using metadata ID=%q from registry for db %q", base.MD(db.MetadataID), base.MD(dbName))
770771
return db.MetadataID
771772
}
772773
if db.MetadataID == defaultMetadataID {
773-
defaultMetadataIDInUse = true
774+
// do not return standardMetadataID here in case there was a different metadata ID assigned to this database
775+
defaultMetadataIDDb = config.Name
774776
}
775777
}
776778
}
777779

778780
// If the default metadata ID is already in use in the registry by a different database, use standard ID.
779-
if defaultMetadataIDInUse {
781+
if defaultMetadataIDDb != "" {
782+
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))
780783
return standardMetadataID
781784
}
782-
783785
// If the database config doesn't include _default._default, use standard ID
784786
if config.Scopes != nil {
785787
defaultFound := false
@@ -791,6 +793,7 @@ func (b *bootstrapContext) computeMetadataID(ctx context.Context, registry *Gate
791793
}
792794
}
793795
if !defaultFound {
796+
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))
794797
return standardMetadataID
795798
}
796799
}
@@ -805,11 +808,12 @@ func (b *bootstrapContext) computeMetadataID(ctx context.Context, registry *Gate
805808
}
806809

807810
if exists && syncInfo.MetadataID != defaultMetadataID {
811+
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))
808812
return standardMetadataID
809813
}
810814

815+
base.InfofCtx(ctx, base.KeyConfig, "Using default metadata ID %q for db %q", base.MD(defaultMetadataID), base.MD(config.Name))
811816
return defaultMetadataID
812-
813817
}
814818

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

0 commit comments

Comments
 (0)