Commit 21d885b
Defer cursor SF trim to durable-ack when opted in
Add request_durable_ack=on opt-in to the cursor store-and-forward
sender. When opted in, OK frames no longer advance the trim watermark
on the on-disk SF; only STATUS_DURABLE_ACK frames do. This closes the
last data-loss window in the QWP ingestion path: with OK-driven trim,
a primary that committed to its WAL but failed before uploading to
object store could lose rows whose only remaining copy was already
trimmed from the client's SF.
The opt-in negotiates with the server through the WebSocket upgrade.
The client sends X-QWP-Request-Durable-Ack: true in the upgrade
request, and the server echoes X-QWP-Durable-Ack: enabled in the 101
response when (and only when) it has a durable-ack registry. If the
client opted in but the server did not echo the confirmation, connect
fails immediately rather than letting the SF grow until the disk
fills -- a loud failure beats silent storage exhaustion.
Trim accounting tracks per-table seqTxn watermarks in
CursorWebSocketSendLoop. OK frames enqueue (wireSeq, table list,
seqTxns) into a FIFO; durable-ack frames update watermarks and drain
the FIFO head whenever every table referenced by the head entry is at
or above its watermark. Empty OKs (zero tables) and DROP_AND_CONTINUE
rejections are trivially durable so the queue stays drained. swap
on reconnect clears the queue and watermarks; the post-reconnect
replay restores them as the server re-OKs the same wireSeq range.
Tests:
- 13 unit tests in CursorWebSocketSendLoopDurableAckTest cover OK-only
growth, durable-ack drain, multi-table cumulative drain, partial vs
full coverage, NACK handling, backwards-watermark rejection, and
reconnect state reset.
- 4 integration tests in DurableAckIntegrationTest exercise the
connect-string parser (invalid value rejected, off opts out cleanly,
on requires server support) and end-to-end deferred-trim through a
TestWebSocketServer.
- CursorWebSocketSendLoopDurableAckFuzzTest runs 500 iterations of
randomised OK/durable-ack interleavings and asserts the watermark
invariants on every iteration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a6b45c3 commit 21d885b
7 files changed
Lines changed: 1469 additions & 13 deletions
File tree
- core/src
- main/java/io/questdb/client/cutlass
- http/client
- qwp/client
- sf/cursor
- test/java/io/questdb/client/test/cutlass/qwp
- client/sf
- cursor
- websocket
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
| |||
295 | 303 | | |
296 | 304 | | |
297 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
298 | 316 | | |
299 | 317 | | |
300 | 318 | | |
| |||
589 | 607 | | |
590 | 608 | | |
591 | 609 | | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
592 | 627 | | |
593 | 628 | | |
594 | 629 | | |
| |||
1017 | 1052 | | |
1018 | 1053 | | |
1019 | 1054 | | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
1020 | 1062 | | |
1021 | 1063 | | |
1022 | 1064 | | |
| |||
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1766 | 1766 | | |
1767 | 1767 | | |
1768 | 1768 | | |
1769 | | - | |
| 1769 | + | |
| 1770 | + | |
1770 | 1771 | | |
1771 | 1772 | | |
1772 | 1773 | | |
| |||
1834 | 1835 | | |
1835 | 1836 | | |
1836 | 1837 | | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
1837 | 1852 | | |
1838 | 1853 | | |
1839 | 1854 | | |
| |||
0 commit comments