Skip to content

Commit

Permalink
CBG-3586: [3.1.4 backport] log bucket and groupID during config search (
Browse files Browse the repository at this point in the history
#6667)

* CBG-3585 log bucket and groupID during config search (#6564)

* Replace `%w` with `%s` inside log functions. Only `fmt.Errorf` supports `%w` (#6494)

---------

Co-authored-by: Tor Colvin <[email protected]>
Co-authored-by: Ben Brooks <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2024
1 parent 21cf11f commit 621f276
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions db/background_mgr_attachment_compaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ func (a *AttachmentCompactionManager) handleAttachmentCompactionRollbackError(ct
// to rollback any phase for attachment compaction we need to purge all persisted dcp metadata
err = a.PurgeDCPMetadata(ctx, dataStore, database, keyPrefix)
if err != nil {
base.WarnfCtx(ctx, "error occurred during purging of dcp metadata: %w", err)
base.WarnfCtx(ctx, "error occurred during purging of dcp metadata: %s", err)
return false, err
}
if phase == MarkPhase {
// initialise new compaction run as we want to start the phase mark again in event of rollback
err = a.Init(ctx, options, nil)
if err != nil {
base.WarnfCtx(ctx, "error on initialization of new run after rollback has been indicated, %w", err)
base.WarnfCtx(ctx, "error on initialization of new run after rollback has been indicated: %s", err)
return false, err
}
} else {
Expand Down
20 changes: 10 additions & 10 deletions rest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,23 +1454,23 @@ func (sc *ServerContext) migrateV30Configs(ctx context.Context) error {
if getErr == base.ErrNotFound {
continue
} else if getErr != nil {
base.InfofCtx(ctx, base.KeyConfig, "Unable to retrieve 3.0 config during config migration for bucket: %s, groupID: %s: %w", base.MD(bucketName), base.MD(groupID), getErr)
base.InfofCtx(ctx, base.KeyConfig, "Unable to retrieve 3.0 config during config migration for bucket: %s, groupID: %s: %s", base.MD(bucketName), base.MD(groupID), getErr)
continue
}

base.InfofCtx(ctx, base.KeyConfig, "Found legacy persisted config for database %s - migrating to db registry.", base.MD(dbConfig.Name))
base.InfofCtx(ctx, base.KeyConfig, "Found legacy persisted config for database %s in bucket %s, groupID %s - migrating to db registry.", base.MD(dbConfig.Name), base.MD(bucketName), base.MD(groupID))
_, insertErr := sc.BootstrapContext.InsertConfig(ctx, bucketName, groupID, &dbConfig)
if insertErr != nil {
if insertErr == base.ErrAlreadyExists {
base.DebugfCtx(ctx, base.KeyConfig, "Found legacy config for database %s, but already exists in registry.", base.MD(dbConfig.Name))
base.DebugfCtx(ctx, base.KeyConfig, "Found legacy config for database %s in bucket %s, groupID: %s, but already exists in registry.", base.MD(dbConfig.Name), base.MD(bucketName), base.MD(groupID))
} else {
base.InfofCtx(ctx, base.KeyConfig, "Unable to persist migrated v3.0 config for bucket %s groupID %s: %w", base.MD(bucketName), base.MD(groupID), insertErr)
base.InfofCtx(ctx, base.KeyConfig, "Unable to persist migrated v3.0 config for bucket %s groupID %s: %s", base.MD(bucketName), base.MD(groupID), insertErr)
continue
}
}
removeErr := sc.BootstrapContext.Connection.DeleteMetadataDocument(ctx, bucketName, PersistentConfigKey30(ctx, groupID), legacyCas)
if removeErr != nil {
base.InfofCtx(ctx, base.KeyConfig, "Failed to remove legacy config for database %s.", base.MD(dbConfig.Name))
base.InfofCtx(ctx, base.KeyConfig, "Failed to remove legacy config for database %s in bucket %s, groupID %s: %s", base.MD(dbConfig.Name), base.MD(bucketName), base.MD(groupID), base.MD(removeErr))
}
}
return nil
Expand Down Expand Up @@ -1555,7 +1555,7 @@ func (sc *ServerContext) _fetchDatabase(ctx context.Context, dbName string) (fou
cnf.CertPath = sc.Config.Bootstrap.X509CertPath
cnf.KeyPath = sc.Config.Bootstrap.X509KeyPath
}
base.TracefCtx(ctx, base.KeyConfig, "Got config for bucket %q with cas %d", bucket, cas)
base.TracefCtx(ctx, base.KeyConfig, "Got database config %s for bucket %q with cas %d and groupID %q", base.MD(dbName), base.MD(bucket), cas, base.MD(sc.Config.Bootstrap.ConfigGroupID))
return true, nil
}

Expand Down Expand Up @@ -1677,20 +1677,20 @@ func (sc *ServerContext) FetchConfigs(ctx context.Context, isInitialStartup bool
fetchedConfigs := make(map[string]DatabaseConfig, len(buckets))
for _, bucket := range buckets {

base.TracefCtx(ctx, base.KeyConfig, "Checking for configs for group %q from bucket %q", sc.Config.Bootstrap.ConfigGroupID, bucket)
base.TracefCtx(ctx, base.KeyConfig, "Checking for configs for group %q from bucket %q", sc.Config.Bootstrap.ConfigGroupID, base.MD(bucket))
configs, err := sc.BootstrapContext.GetDatabaseConfigs(ctx, bucket, sc.Config.Bootstrap.ConfigGroupID)
if err != nil {
// Unexpected error fetching config - SDK has already performed retries, so we'll treat it as a registry removal
// this could be due to invalid JSON or some other non-recoverable error.
if isInitialStartup {
base.WarnfCtx(ctx, "Unable to fetch config for group %q from bucket %q on startup: %v", sc.Config.Bootstrap.ConfigGroupID, bucket, err)
base.WarnfCtx(ctx, "Unable to fetch configs for group %q from bucket %q on startup: %v", sc.Config.Bootstrap.ConfigGroupID, base.MD(bucket), err)
} else {
base.DebugfCtx(ctx, base.KeyConfig, "Unable to fetch config for group %q from bucket %q: %v", sc.Config.Bootstrap.ConfigGroupID, bucket, err)
base.DebugfCtx(ctx, base.KeyConfig, "Unable to fetch configs for group %q from bucket %q: %v", sc.Config.Bootstrap.ConfigGroupID, base.MD(bucket), err)
}
continue
}
if len(configs) == 0 {
base.DebugfCtx(ctx, base.KeyConfig, "Bucket %q did not contain config for group %q", bucket, sc.Config.Bootstrap.ConfigGroupID)
base.DebugfCtx(ctx, base.KeyConfig, "Bucket %q did not contain any configs for group %q", base.MD(bucket), sc.Config.Bootstrap.ConfigGroupID)
continue
}
for _, cnf := range configs {
Expand Down
6 changes: 3 additions & 3 deletions rest/server_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,7 @@ func (sc *ServerContext) initializeCouchbaseServerConnections(ctx context.Contex
}

if count > 0 {
base.InfofCtx(ctx, base.KeyConfig, "Successfully fetched %d database configs from buckets in cluster", count)
base.InfofCtx(ctx, base.KeyConfig, "Successfully fetched %d database configs for group %q from buckets in cluster", count, sc.Config.Bootstrap.ConfigGroupID)
} else {
base.WarnfCtx(ctx, "Config: No database configs for group %q. Continuing startup to allow REST API database creation", sc.Config.Bootstrap.ConfigGroupID)
}
Expand All @@ -2060,10 +2060,10 @@ func (sc *ServerContext) initializeCouchbaseServerConnections(ctx context.Contex
base.DebugfCtx(ctx, base.KeyConfig, "Fetching configs from buckets in cluster for group %q", sc.Config.Bootstrap.ConfigGroupID)
count, err := sc.fetchAndLoadConfigs(ctx, false)
if err != nil {
base.WarnfCtx(ctx, "Couldn't load configs from bucket when polled: %v", err)
base.WarnfCtx(ctx, "Couldn't load configs from bucket for group %q when polled: %v", sc.Config.Bootstrap.ConfigGroupID, err)
}
if count > 0 {
base.InfofCtx(ctx, base.KeyConfig, "Successfully fetched %d database configs from buckets in cluster", count)
base.InfofCtx(ctx, base.KeyConfig, "Successfully fetched %d database configs for group %d from buckets in cluster", count, sc.Config.Bootstrap.ConfigGroupID)
}
}
}
Expand Down

0 comments on commit 621f276

Please sign in to comment.