You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/reference/csharp.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -179,6 +179,19 @@ db.PromoteToPrimary();
179
179
// Now writes are accepted
180
180
```
181
181
182
+
When the object store enforces conditional writes, promotion acquires the primary lease by advancing its epoch with a compare-and-swap. If another node already holds the lease the call is refused with `ErrorCode.Precondition` (the node stays a working replica for an orchestrator to retry); it throws `ErrorCode.InvalidArgs` if the node is already a primary. The active lease epoch is observable through `DbStats.PrimaryEpoch` (held by this node) and `DbStats.SeenEpoch` (highest observed).
183
+
184
+
```csharp
185
+
try
186
+
{
187
+
db.PromoteToPrimary();
188
+
}
189
+
catch (TidesDBExceptionex) when (ex.ErrorCode==ErrorCode.Precondition)
190
+
{
191
+
// Another node won the promotion race; remain a replica and let the orchestrator retry.
192
+
}
193
+
```
194
+
182
195
**Object Store Configuration Options**
183
196
184
197
| Property | Type | Default | Description |
@@ -975,8 +988,9 @@ catch (TidesDBException ex)
975
988
-`TDB_ERR_LOCKED` (-12) · Database is locked
976
989
-`TDB_ERR_READONLY` (-13) · Database is read-only
977
990
-`TDB_ERR_BUSY` (-14) · Resource busy
991
+
-`TDB_ERR_PRECONDITION` (-15) · A conditional object-store write failed its precondition (HTTP 412). Raised by single-writer fencing — e.g. `PromoteToPrimary` when another node already holds the primary lease
978
992
979
-
These map to the `ErrorCode` enum (`ErrorCode.Locked`, `ErrorCode.Readonly`, `ErrorCode.Busy`, …) exposed on `TidesDBException.ErrorCode`.
993
+
These map to the `ErrorCode` enum (`ErrorCode.Locked`, `ErrorCode.Readonly`, `ErrorCode.Busy`, `ErrorCode.Precondition`, …) exposed on `TidesDBException.ErrorCode`.
980
994
981
995
## Complete Example
982
996
@@ -1237,7 +1251,12 @@ Console.WriteLine($"Unified is flushing: {dbStats.UnifiedIsFlushing}");
1237
1251
1238
1252
// Object store stats (when enabled)
1239
1253
Console.WriteLine($"Object store enabled: {dbStats.ObjectStoreEnabled}");
1254
+
Console.WriteLine($"Object store connector: {dbStats.ObjectStoreConnector}");
0 commit comments