Commit ba4d458
Fix six moderate findings in the SF dictionary paths
Guards that don't guard. Already closed by the varint packing change:
readVarintAt returns -1 for a truncated varint instead of 0 with its end
at the limit, so a caller's `p > limit` bail-out can fire at an exact
boundary. It had no test; one now feeds a delta declaring two entries
while carrying one, ending precisely on the boundary that used to slip
through. Reverted to the indistinguishable shape it reports
expected:<0> but was:<2> -- the mirror claiming symbols it holds no
bytes for, which the next catch-up would ship as a chunk whose
deltaCount exceeds its payload.
DIR_MODE_SHARED. The javadoc claimed umask governed it "exactly as it
does for the sf_dir these live under", but sf_dir was created with an
explicit 0755 and umask can only CLEAR bits -- so under umask 002 the
lock directory became group-writable while sf_dir did not, and a second
uid still could not create its slot directory. build() failed one level
before the problem the mode existed to solve. sf_dir now gets the same
mode, and the mode is 01777 rather than 0777: without the sticky bit any
local user with write access can unlink another process's lock file,
which does not release that process's flock but does free the pathname,
so the next acquirer mints a second inode and locks it successfully.
umask masks only the rwx bits, so the restricted-deletion semantics
survive every umask and the usual 022 still yields 0755 plus sticky. The
slot directory itself stays 0755 -- only its creator writes it.
Foreground retry observability. Retrying an endpoint-policy rejection is
what the contract demands, but dispatchError ran only in the terminal
branches, so the retry was programmatically invisible: a revoked token
produced a throttled slf4j WARN and nothing else, in a library that
ships embedded in user applications. flush() kept returning success
until SF filled, and the failure then surfaced as "cursor ring
backpressured ... sf_max_total_bytes too small" -- pointing the operator
at disk sizing. The retry branches now dispatch a RETRIABLE SenderError,
and lastReconnectError is promoted from a connectLoop local that never
escaped to a volatile field, which close()'s drain-timeout throw uses to
name the real cause.
scanRecoveredChunks. It rejected entryCount <= 0 but never checked that
entryBytes actually holds entryCount well-formed entries. The CRC proves
the bytes are what was written, not that the header triple is
consistent, and the only write-side guard sits behind an assert that
production never runs. Such a chunk is now rejected during the scan, so
the trusted prefix ends there as it would on a CRC failure, instead of
decodeLoadedSymbols discovering it later and quarantining the whole slot.
ensureSentDictCapacity. The MAX_SENT_DICT_BYTES arm deliberately latches
via recordFatal before throwing, because accumulateSentDict runs AFTER
the frame's sendBinary and a bare throw unwinds into a reconnect that
replays the same frame. The allocation one line below had no such latch,
so a genuine out-of-memory took exactly the livelock the ceiling arm
exists to prevent. It now latches too.
PersistedSymbolDict.close(). It set closed = true and then ran munmap and
truncate unguarded, so a throw from either stranded the scratch buffer
and the fd for the process's lifetime -- a retry short-circuits on
`closed`. Each step is now in its own try/catch, as CursorSendEngine's
close already was.
Two tests were updated rather than added: the one asserting the scan
ACCEPTED an inconsistent chunk now asserts it ends the trusted prefix
(that path's exception-type change stays pinned on its reachable sibling
in CursorSendEngineTest), and SlotLockTest's mode assertion follows the
constant. The OOM latch and the close hardening have no test: neither an
Unsafe allocation failure nor a throwing munmap is injectable through
any existing seam.
Full client suite: 2702 tests green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent f9bb589 commit ba4d458
10 files changed
Lines changed: 298 additions & 63 deletions
File tree
- core/src
- main/java/io/questdb/client
- cutlass/qwp/client
- sf/cursor
- std
- test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1550 | 1550 | | |
1551 | 1551 | | |
1552 | 1552 | | |
1553 | | - | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
1554 | 1558 | | |
1555 | 1559 | | |
1556 | 1560 | | |
| |||
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3347 | 3347 | | |
3348 | 3348 | | |
3349 | 3349 | | |
3350 | | - | |
3351 | | - | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
3352 | 3360 | | |
3353 | 3361 | | |
3354 | 3362 | | |
3355 | 3363 | | |
3356 | 3364 | | |
3357 | | - | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
3358 | 3368 | | |
3359 | 3369 | | |
3360 | 3370 | | |
| |||
Lines changed: 77 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
379 | 385 | | |
380 | 386 | | |
381 | 387 | | |
| |||
1599 | 1605 | | |
1600 | 1606 | | |
1601 | 1607 | | |
1602 | | - | |
| 1608 | + | |
1603 | 1609 | | |
1604 | 1610 | | |
1605 | 1611 | | |
| |||
1665 | 1671 | | |
1666 | 1672 | | |
1667 | 1673 | | |
| 1674 | + | |
| 1675 | + | |
1668 | 1676 | | |
1669 | 1677 | | |
1670 | 1678 | | |
| |||
1703 | 1711 | | |
1704 | 1712 | | |
1705 | 1713 | | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
1706 | 1717 | | |
1707 | 1718 | | |
1708 | 1719 | | |
| |||
1821 | 1832 | | |
1822 | 1833 | | |
1823 | 1834 | | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
1824 | 1874 | | |
1825 | 1875 | | |
1826 | 1876 | | |
| |||
2341 | 2391 | | |
2342 | 2392 | | |
2343 | 2393 | | |
| 2394 | + | |
2344 | 2395 | | |
2345 | 2396 | | |
2346 | 2397 | | |
| |||
2552 | 2603 | | |
2553 | 2604 | | |
2554 | 2605 | | |
2555 | | - | |
2556 | | - | |
2557 | | - | |
2558 | | - | |
2559 | | - | |
2560 | | - | |
2561 | | - | |
2562 | | - | |
2563 | | - | |
2564 | | - | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
2565 | 2620 | | |
2566 | | - | |
2567 | | - | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
2568 | 2632 | | |
2569 | 2633 | | |
2570 | 2634 | | |
| |||
Lines changed: 82 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
502 | 508 | | |
503 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
504 | 513 | | |
505 | 514 | | |
506 | 515 | | |
507 | 516 | | |
508 | 517 | | |
509 | 518 | | |
510 | 519 | | |
511 | | - | |
| 520 | + | |
| 521 | + | |
512 | 522 | | |
513 | 523 | | |
514 | 524 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
522 | 539 | | |
523 | 540 | | |
524 | 541 | | |
525 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
526 | 546 | | |
527 | 547 | | |
528 | 548 | | |
529 | 549 | | |
530 | | - | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
531 | 554 | | |
532 | 555 | | |
533 | 556 | | |
| |||
800 | 823 | | |
801 | 824 | | |
802 | 825 | | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
803 | 829 | | |
804 | 830 | | |
805 | 831 | | |
| |||
808 | 834 | | |
809 | 835 | | |
810 | 836 | | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
811 | 882 | | |
812 | 883 | | |
813 | 884 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
89 | 105 | | |
90 | 106 | | |
91 | 107 | | |
| |||
0 commit comments