Commit 03afa61
feat(ilp): opt-in sf_fsync_on_flush, fix sf_fsync default doc lie
Sender.storeAndForwardFsync's Javadoc claimed the default sf_fsync=off
"runs fsync on rotation and on explicit flush()". In practice flush()
never called segmentLog.fsync() — the only production fsync paths were
per-append (gated on fsync_each_append, the sf_fsync=on path),
rotation (rare), and new-segment header creation (rare). With default
config a sender that flushes coarsely between rotations was leaving
all bytes in the OS page cache; an OS crash would lose them despite
the docs implying durability.
Two-part fix:
1. Doc honesty (Sender.java):
storeAndForwardFsync rewritten to spell out exactly what
sf_fsync=off and sf_fsync=on mean. The default leaves bytes
between rotations in the page cache — process crashes survive,
OS crashes don't.
2. Opt-in fsync-on-flush:
New knob storeAndForwardFsyncOnFlush(boolean) on the builder,
parsed as sf_fsync_on_flush=on/off in the connect string. When
enabled, every flush() (and the implicit flush in close()) routes
a fsync request to the I/O thread before returning. Off by
default — small-batch + frequent-flush senders pay one disk fsync
per call, which is unacceptable for high-rate workloads.
The fsync runs on the I/O thread because SegmentLog is single-
threaded (the I/O thread owns every read/write/trim/rotate).
Calling segmentLog.fsync() from the user thread would race
against an in-flight trim() (which may force-rotate the active
under per-frame trim) or append() from a concurrent send. The
signal pattern is the same one used by ping/pong: user sets
fsyncRequested + waits on fsyncComplete; I/O thread observes the
flag at the top of its iteration, performs the fsync, publishes
outcome via fsyncError + fsyncComplete. Concurrent callers are
serialised by fsyncLock so each gets its own round-trip.
Tests:
- testFlushDoesNotFsyncByDefault (SfIntegrationTest): with
fsyncOnFlush=false the FsyncCountingFacade observes ZERO fsyncs
during flush() — proves we did not regress the small-batch
hot path.
- testFlushFsyncsWhenOptedIn (SfIntegrationTest): with
fsyncOnFlush=true the same counter observes >= 1 fsync per
flush() — proves the wiring is end-to-end.
- testSfFsyncOnFlushParses (SfFromConfigTest): connect-string
round-trip.
- testInvalidSfFsyncOnFlushValueRejected (SfFromConfigTest): bad
value rejected with a useful message.
- testSfFsyncOnFlushOnTcpRejected (SfFromConfigTest): TCP transport
rejects the WebSocket-only knob.
Full suite: 1981 tests pass, zero regressions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e38b4d5 commit 03afa61
5 files changed
Lines changed: 459 additions & 5 deletions
File tree
- core/src
- main/java/io/questdb/client
- cutlass/qwp/client
- test/java/io/questdb/client/test/cutlass/qwp/client/sf
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
| 634 | + | |
634 | 635 | | |
635 | 636 | | |
636 | 637 | | |
| |||
968 | 969 | | |
969 | 970 | | |
970 | 971 | | |
971 | | - | |
| 972 | + | |
| 973 | + | |
972 | 974 | | |
973 | 975 | | |
974 | 976 | | |
| |||
1640 | 1642 | | |
1641 | 1643 | | |
1642 | 1644 | | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
1646 | 1657 | | |
1647 | 1658 | | |
1648 | 1659 | | |
| |||
1652 | 1663 | | |
1653 | 1664 | | |
1654 | 1665 | | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
1655 | 1692 | | |
1656 | 1693 | | |
1657 | 1694 | | |
| |||
2118 | 2155 | | |
2119 | 2156 | | |
2120 | 2157 | | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
2121 | 2170 | | |
2122 | 2171 | | |
2123 | 2172 | | |
| |||
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
175 | 180 | | |
176 | 181 | | |
177 | 182 | | |
| |||
350 | 355 | | |
351 | 356 | | |
352 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
353 | 385 | | |
354 | 386 | | |
355 | 387 | | |
| |||
361 | 393 | | |
362 | 394 | | |
363 | 395 | | |
| 396 | + | |
364 | 397 | | |
365 | 398 | | |
366 | 399 | | |
| |||
579 | 612 | | |
580 | 613 | | |
581 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
582 | 621 | | |
583 | 622 | | |
584 | 623 | | |
| |||
866 | 905 | | |
867 | 906 | | |
868 | 907 | | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
869 | 922 | | |
870 | 923 | | |
871 | 924 | | |
| |||
1234 | 1287 | | |
1235 | 1288 | | |
1236 | 1289 | | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1237 | 1312 | | |
1238 | 1313 | | |
1239 | 1314 | | |
| |||
Lines changed: 85 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
162 | 173 | | |
163 | 174 | | |
164 | 175 | | |
| |||
490 | 501 | | |
491 | 502 | | |
492 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
493 | 553 | | |
494 | 554 | | |
495 | 555 | | |
| |||
641 | 701 | | |
642 | 702 | | |
643 | 703 | | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
644 | 728 | | |
645 | 729 | | |
646 | 730 | | |
| |||
652 | 736 | | |
653 | 737 | | |
654 | 738 | | |
655 | | - | |
| 739 | + | |
656 | 740 | | |
657 | 741 | | |
658 | 742 | | |
| |||
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
502 | 549 | | |
503 | 550 | | |
504 | 551 | | |
| |||
0 commit comments