Commit 826cdc4
v2.5.8: revert CosmoKvConnection RW lock — keep Executor AsyncLocal
The v2.5.7 attempt at allowing concurrent reads on CosmoKvConnection
backfired badly on marivil:
- First design ("drain N reader slots" for writes) starved writers
under sustained read load. Marivil stress run: 252 audit-write
failures, 21 RelayWorker failures, 16 WebhookWorker failures,
nearly all "txn_busy" or 30s timeout. Throughput collapsed to ~0.
- Second attempt (writer-priority gate) deadlocked subtly under
xUnit's parallel-test harness — fine in isolation, intermittent
failures under load.
A correct async RW lock with bounded fairness needs more care than
this session can give it. Revert CosmoKvConnection to its prior
single SemaphoreSlim(1, 1). The Executor-side AsyncLocal<IKvAccess?>
change stays: it's harmless under serial access (the connection lock
already serialises everything) and removes the "shared mutable
_kv field" hazard that would otherwise need re-doing whenever the RW
lock returns. Same with the ConcurrentDictionary swap for
_defaultExprCache — pure safety, no behaviour change under serial.
Marivil is back on cosmokvd v0.3.4 + CosmoSQLClient 2.5.6 (the
known-good combo); v2.5.7 + v0.3.5 stay on NuGet/Docker Hub as
"known-bad — do not deploy".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c74256e commit 826cdc4
4 files changed
Lines changed: 23 additions & 269 deletions
File tree
- src/CosmoSQLClient.CosmoKv
- tests/CosmoSQLClient.CosmoKv.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | | - | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
182 | 185 | | |
183 | 186 | | |
184 | 187 | | |
185 | | - | |
| 188 | + | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
| |||
203 | 206 | | |
204 | 207 | | |
205 | 208 | | |
206 | | - | |
| 209 | + | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
| |||
231 | 234 | | |
232 | 235 | | |
233 | 236 | | |
234 | | - | |
| 237 | + | |
235 | 238 | | |
236 | 239 | | |
237 | 240 | | |
| |||
283 | 286 | | |
284 | 287 | | |
285 | 288 | | |
286 | | - | |
| 289 | + | |
287 | 290 | | |
288 | 291 | | |
289 | 292 | | |
| |||
333 | 336 | | |
334 | 337 | | |
335 | 338 | | |
336 | | - | |
| 339 | + | |
337 | 340 | | |
338 | | - | |
| 341 | + | |
339 | 342 | | |
340 | 343 | | |
341 | 344 | | |
342 | 345 | | |
343 | | - | |
| 346 | + | |
344 | 347 | | |
345 | | - | |
| 348 | + | |
346 | 349 | | |
347 | 350 | | |
348 | 351 | | |
349 | 352 | | |
350 | | - | |
| 353 | + | |
351 | 354 | | |
352 | | - | |
| 355 | + | |
353 | 356 | | |
354 | 357 | | |
355 | 358 | | |
| |||
418 | 421 | | |
419 | 422 | | |
420 | 423 | | |
421 | | - | |
422 | | - | |
423 | | - | |
| 424 | + | |
424 | 425 | | |
425 | 426 | | |
426 | 427 | | |
| |||
Lines changed: 0 additions & 183 deletions
This file was deleted.
0 commit comments