{"record":{"id":"4de09ab8965fc7af","repo":"gastownhall/beads","slug":"record-clone-id-w","errorCode":null,"errorMessage":"record clone_id: %w","messagePattern":"record clone_id: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init_proxied_server.go","lineNumber":376,"sourceCode":"//\n// It is separate from the identity because its LIFETIME is: the identity is\n// written once and then adopted forever, while these four describe the clone\n// running init and are refreshed every time it runs. In the refusable one-time\n// write, a re-init on a shared database would silently stop recording them.\nfunc recordProxiedInitTrackingState(ctx context.Context, provider uow.UnitOfWorkProvider, repoID, cloneID string) error {\n\treturn uow.RunTx(ctx, provider, func(ctx context.Context, uw uow.UnitOfWork) (string, error) {\n\t\tcfg := uw.ConfigUseCase()\n\t\t// An absent fingerprint is recorded as nothing rather than as \"\": an\n\t\t// empty row reads back to cross-project verification as a clone whose\n\t\t// fingerprint failed to compute.\n\t\tif repoID != \"\" {\n\t\t\tif err := cfg.SetMetadata(ctx, \"repo_id\", repoID); err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"record repo_id: %w\", err)\n\t\t\t}\n\t\t}\n\t\tif cloneID != \"\" {\n\t\t\tif err := cfg.SetMetadata(ctx, \"clone_id\", cloneID); err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"record clone_id: %w\", err)\n\t\t\t}\n\t\t}\n\t\tif err := cfg.SetMetadata(ctx, \"last_import_time\", time.Now().UTC().Format(time.RFC3339)); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"record last_import_time: %w\", err)\n\t\t}\n\t\tif err := cfg.SetLocalMetadata(ctx, workapi.MetadataKeyVersion, Version); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"record bd_version: %w\", err)\n\t\t}\n\t\treturn \"bd init\", nil\n\t})\n}\n\n// configureProxiedInitDoltRemote adds the sync remote, skipping a name that is\n// already taken.\nfunc configureProxiedInitDoltRemote(ctx context.Context, provider uow.UnitOfWorkProvider, remoteURL string) error {\n\treturn uow.RunTx(ctx, provider, func(ctx context.Context, uw uow.UnitOfWork) (string, error) {\n\t\tremotes, err := uw.DoltRemoteUseCase().ListRemotes(ctx)\n\t\tif err != nil {","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init_proxied_server.go#L358-L394","documentation":"Same seeding transaction as repo_id: this wrapper fires when cfg.SetMetadata(ctx, \"clone_id\", cloneID) fails while recording the clone fingerprint during proxied-server init. It identifies the failing metadata key; the wrapped underlying error carries the actual cause.","triggerScenarios":"bd init in team-server mode with a non-empty cloneID where SetMetadata for clone_id fails — storage unavailable, transaction conflict, or permission denied on the shared database.","commonSituations":"Shared Dolt server restarted mid-init; concurrent init of two clones against the same database causing a transaction conflict; read-only replica pointed at instead of the writable primary.","solutions":["Retry bd init after confirming the team server is healthy","Check for concurrent init runs against the same database and serialize them","Verify write permissions for the connecting user on the metadata table","Read the wrapped underlying error for the driver-level cause"],"exampleFix":"// before\nerr: \"record clone_id: database is locked\"\n// after: avoid concurrent inits on the same shared db; retry\nbd init  # run only one init per clone at a time","handlingStrategy":"retry","validationCode":"// ensure only one init runs per database at a time\nif !acquireInitLock(sharedDBName) {\n    return errors.New(\"another init is in progress for this database\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"record clone_id:\") {\n    log.Printf(\"clone_id write failed: %v\", errors.Unwrap(err))\n    // serialize concurrent inits, then retry bd init\n}","preventionTips":["Serialize bd init runs against the same shared database","Point at the writable primary, not a read-only replica","Keep the team server healthy across the whole init run","Inspect the wrapped cause for lock/permission specifics"],"tags":["init","metadata","dolt","team-server","persistence"],"backgroundTag":"metadata-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}