MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / getDatabaseConfig

Method getDatabaseConfig

rest/config_manager.go:498–520  ·  view source on GitHub ↗

getDatabaseConfig retrieves the database config, and enforces version match. On config not found or mismatched version, will retry with backoff (to wait for in-flight updates to complete). After retry timeout, triggers registry rollback and returns rollback error

(ctx context.Context, bucketName, groupID, dbName string, version string, registry *GatewayRegistry)

Source from the content-addressed store, hash-verified

496// version, will retry with backoff (to wait for in-flight updates to complete). After retry timeout,
497// triggers registry rollback and returns rollback error
498func (b *bootstrapContext) getDatabaseConfig(ctx context.Context, bucketName, groupID, dbName string, version string, registry *GatewayRegistry) (*DatabaseConfig, error) {
499
500 ctx = b.addDatabaseLogContext(ctx, &DbConfig{Name: dbName})
501 config, err := b.getConfigVersionWithRetry(ctx, bucketName, groupID, dbName, version)
502 if err != nil {
503 if err == base.ErrConfigRegistryRollback {
504 base.InfofCtx(ctx, base.KeyConfig, "Registry rollback required for bucket: %s, groupID: %s, dbName:%s", bucketName, groupID, dbName)
505 rollbackErr := b.rollbackRegistry(ctx, bucketName, groupID, dbName, config, registry)
506 // On successful registry rollback, caller needs reload registry
507 if rollbackErr == nil {
508 return nil, base.ErrConfigRegistryReloadRequired
509 }
510 // On unsuccessful rollback due to CAS failure, caller also needs to reload registry
511 if base.IsCasMismatch(rollbackErr) {
512 base.InfofCtx(ctx, base.KeyConfig, "Unsuccessful rollback for db:%s - CAS mismatch", dbName)
513 return nil, base.ErrConfigRegistryReloadRequired
514 }
515 return nil, rollbackErr
516 }
517 return nil, err
518 }
519 return config, nil
520}
521
522// waitForConfigDelete waits for a config file to be deleted. After retry timeout, returns latest cas
523// and version, will backoff retry (to wait for in-flight updates to complete). After retry timeout,

Callers 2

GetDatabaseConfigsMethod · 0.95

Calls 5

addDatabaseLogContextMethod · 0.95
rollbackRegistryMethod · 0.95
InfofCtxFunction · 0.92
IsCasMismatchFunction · 0.92

Tested by

no test coverage detected