{"record":{"id":"31f1a6cab0940526","repo":"tursodatabase/turso","slug":"embedded-replica-path-is-already-open-with-dif","errorCode":null,"errorMessage":"Embedded replica '{path}' is already open with different options.","messagePattern":"Embedded replica '(.+?)' is already open with different options\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoReplicaRegistry.cs","lineNumber":43,"sourceCode":"                .ConfigureAwait(false);\n            return Lease.CreateStandalone(\n                database,\n                new TursoAutomaticSyncCoordinator(database, syncInterval, timeProvider));\n        }\n\n        var path = Path.GetFullPath(options.Path);\n        var fingerprint = Fingerprint.Create(options, syncInterval);\n        Entry entry;\n        lock (Gate)\n        {\n            if (Entries.TryGetValue(path, out entry!))\n            {\n                if (entry.Closing)\n                    throw new InvalidOperationException($\"Embedded replica '{path}' is closing.\");\n                if (!pooling || !entry.Pooling)\n                    throw new InvalidOperationException($\"Embedded replica '{path}' is already open exclusively.\");\n                if (entry.Fingerprint != fingerprint)\n                    throw new InvalidOperationException($\"Embedded replica '{path}' is already open with different options.\");\n\n                checked\n                {\n                    entry.ReferenceCount++;\n                }\n            }\n            else\n            {\n                entry = new Entry(path, pooling, fingerprint)\n                {\n                    ReferenceCount = 1,\n                };\n                entry.Initialization = InitializeAsync(entry, options, syncInterval, timeProvider);\n                Entries.Add(path, entry);\n            }\n        }\n\n        try","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Data/TursoReplicaRegistry.cs#L25-L61","documentation":"The Turso .NET embedded replica registry tracks each open replica file with an options 'fingerprint'. When AcquireAsync is asked for a replica path that is already open with a different set of options (connection string/settings), it refuses to return a second handle because two incompatible configurations would fight over the same local replica. The caller must close the existing instance or reuse the same options.","triggerScenarios":"Calling TursoConnection with embedded replica (AcquireAsync) for a path already registered while passing a connection string or replica options that hash to a different fingerprint than the first opener (e.g. different sync interval, different remote URL, different flags like pooling).","commonSituations":"Opening two TursoConnection instances in the same process pointing at the same local replica file but built from differently ordered/different connection-string parameters; a long-lived singleton connection plus a second ad-hoc connection with tweaked options; mixing pooling and non-pooling usage.","solutions":["Reuse the exact same connection string/options for every connection that targets the same local replica path.","Find and dispose/close the existing connection that opened the replica with the old options before opening with new options.","Use a distinct local replica file path if you genuinely need different replica configurations.","Ensure connection string parameters are normalized (same order, no accidental differences) when constructing connections in different places."],"exampleFix":"// before\nvar a = new TursoConnection(\"Data Source=rep.db;SyncUrl=https://x.turso.io\");\nvar b = new TursoConnection(\"Data Source=rep.db;SyncUrl=https://x.turso.io;Pooling=true\");\n\n// after: identical options for the same replica path\nvar a = new TursoConnection(\"Data Source=rep.db;SyncUrl=https://x.turso.io;Pooling=true\");\nvar b = new TursoConnection(\"Data Source=rep.db;SyncUrl=https://x.turso.io;Pooling=true\");","handlingStrategy":"validation","validationCode":"// Ensure options are identical for the same replica path before opening\nvar opts = \"Data Source=rep.db;SyncUrl=https://x.turso.io;Pooling=true\";\nif (openReplicas.TryGetValue(replicaPath, out var existing) && existing.Options != opts)\n    throw new InvalidOperationException(\"Replica already open with different options; reuse existing options or close it first.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await TursoReplicaRegistry.AcquireAsync(path, options);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"different options\"))\n{\n    // close existing connection or normalize options and retry\n}","preventionTips":["Centralize connection-string construction in one factory so all connections for a replica share identical options.","Keep a registry of open replica connections and reuse them instead of opening new ones.","Never mix pooling and non-pooling access to the same replica path.","Use one distinct local file per distinct replica configuration."],"tags":["dotnet","embedded-replica","connection","options-mismatch"],"backgroundTag":"conflicting-config-options","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-09-06T07:15:26.990Z","contentChangedAt":"2026-09-06T07:15:26.990Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}