{"record":{"id":"7608427f7004a103","repo":"temporalio/temporal","slug":"error-while-updating-cluster-metadata-w","errorCode":null,"errorMessage":"error while updating cluster metadata: %w","messagePattern":"error while updating cluster metadata: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"temporal/fx.go","lineNumber":866,"sourceCode":"\t\tupdateDBRecord = true\n\t}\n\n\tif updateIndexSearchAttributes(initialIndexSearchAttributes, currentClusterDBRecord) {\n\t\tupdateDBRecord = true\n\t}\n\n\tif !updateDBRecord {\n\t\treturn nil\n\t}\n\n\tapplied, err := clusterMetadataManager.SaveClusterMetadata(\n\t\tctx,\n\t\t&persistence.SaveClusterMetadataRequest{\n\t\t\tClusterMetadata: currentClusterDBRecord.ClusterMetadata,\n\t\t\tVersion:         currentClusterDBRecord.Version,\n\t\t})\n\tif !applied || err != nil {\n\t\treturn fmt.Errorf(\"error while updating cluster metadata: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc overwriteCurrentClusterMetadataWithDBRecord(\n\tsvc *config.Config,\n\tcurrentClusterDBRecord *persistence.GetClusterMetadataResponse,\n\tlogger log.Logger,\n) {\n\tclusterMetadata := svc.ClusterMetadata\n\tif currentClusterDBRecord.IsGlobalNamespaceEnabled && !clusterMetadata.EnableGlobalNamespace {\n\t\tlogger.Warn(\n\t\t\tmismatchLogMessage,\n\t\t\ttag.Key(\"clusterMetadata.EnableGlobalNamespace\"),\n\t\t\ttag.IgnoredValue(clusterMetadata.EnableGlobalNamespace),\n\t\t\ttag.Value(currentClusterDBRecord.IsGlobalNamespaceEnabled))\n\t\tsvc.ClusterMetadata.EnableGlobalNamespace = currentClusterDBRecord.IsGlobalNamespaceEnabled\n\t}","sourceCodeStart":848,"sourceCodeEnd":884,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/temporal/fx.go#L848-L884","documentation":"Error updating cluster metadata (e.g. persisting cluster name / initial cluster registration) during temporal server bootstrap via fx; the wrapped error comes from the cluster metadata manager.","triggerScenarios":"initCurrentClusterMetadataRecord calls SaveClusterMetadata with the current record and version; applied == false (optimistic concurrency conflict — another writer changed the record) or err != nil.","commonSituations":"Two history nodes racing to update cluster metadata during rolling restart; the metadata version advanced concurrently; DB write failure or timeout.","solutions":["Retry the operation; a concurrent writer likely won (applied=false)","Check the wrapped error for DB-level failures","Serialize cluster metadata bootstrap (single node / leader) for initial cluster setup"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := startServer(ctx)\nif err != nil && strings.Contains(err.Error(), \"error while updating cluster metadata\") {\n    // optimistic concurrency: another node won; retry with fresh version\n    return retry.Do(func() error { return startServer(ctx) },\n        retry.Attempts(3), retry.Delay(backoff))\n}","preventionTips":["Only one leader should perform metadata updates during bootstrap","Use retries with backoff for conditional metadata writes","Avoid rolling restarts that trigger simultaneous metadata writes"],"tags":["cluster-metadata","concurrency","persistence","optimistic-concurrency"],"backgroundTag":"optimistic-concurrency-conflict","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}