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: sdk/cosmos/azure_data_cosmos_driver/docs/ErrorCodesAndRetries.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,16 +12,18 @@ The Rust driver retries writes by default for retryable status codes. This is sa
12
12
13
13
### Idempotency Requirements
14
14
15
-
For write retries to be safe, customers must use ETag preconditions (`If-Match` headers) on replace and upsert operations. Without ETags, a retried write could silently overwrite a concurrent update. This is a best practice regardless of retries — ETags protect against lost updates from concurrent writers.
16
-
17
-
| Operation | Idempotent? | Retry safe? |
18
-
|-----------|-------------|-------------|
19
-
| Create | Yes (409 on duplicate) | Always |
20
-
| Delete | Yes (404 on duplicate) | Always |
21
-
| Replace / Upsert | With ETag precondition | Yes — 412 on stale ETag prevents silent overwrites |
22
-
| Replace / Upsert | Without ETag | No — risk of lost update on retry |
| Stored Procedure | No |**Never** — retries disabled |
15
+
Write retries are not strictly idempotent — the initial attempt and a retry may return different status codes (e.g., create returns 201 on success, then 409 on retry). What makes retries "safe" is that the final state of the resource is the same regardless of how many times the operation is executed, and the non-2xx status codes are deterministic signals the application can handle.
16
+
17
+
For replace and upsert operations, customers must use ETag preconditions (`If-Match` headers) to enable optimistic locking. Without ETags, there is no concurrency control — concurrent writers or retried writes can silently overwrite each other.
18
+
19
+
| Operation | Idempotent? | Retry safe? | Initial attempt | On retry (duplicate) | App must handle |
0 commit comments