Commit 172cfe6
Fix SF recovery, lock and quarantine safety bugs
Address blocking review findings in the store-and-forward paths.
SegmentRing.openExisting no longer detaches the active segment from
`opened` before the ring owns it: `new SegmentRing` and the sealed-add
loop can throw (ObjList growth, native OOM), and the catch iterated only
`opened`, leaking the active segment's mapping and fd. Ownership now
transfers in one step and `opened` is cleared last.
PersistedSymbolDict.open gains the in-flight holder MmapSegment already
uses. Recovery reads the file through a mapping, and pre-JDK-21 HotSpot
delivers an unsafe-access fault at the method's return, past the inner
catch; without a holder the built instance's fd and buffer leak and the
fault escapes build() instead of degrading to full-dictionary frames.
commitMappedChunk checksums the append mapping with Crc32c.updateUnsafe
rather than the native update. ff.allocate can leave the window over
uncommitted blocks (ENOSPC, quota, a crash-torn tail); a SIGBUS there
aborts the JVM through JNI but is a catchable InternalError at an Unsafe
site, matching scanFrames.
SlotLock.removeOrphanLogical acquires the lock before unlinking it.
Removing a file another party holds frees the pathname without releasing
the flock, so the next acquireLogical locks a second inode -- two owners
of a mutual-exclusion lock. QwpWebSocketSender.close carries a
reclaim-logical-lock flag that connect()'s rollback clears, so a failed
connect no longer unlinks the lock Sender.build() still holds.
Sender.build reports an abandoned quarantined slot through the configured
errorHandler, not only via LOG.error: the client ships slf4j-api with no
binding, so an embedder without a provider would learn of the loss
nowhere.
Files.DIR_MODE_SHARED's javadoc no longer claims the sticky bit survives:
Linux mkdir(2) masks it off, so the restricted-deletion guarantee is
best-effort and lock safety rests on the acquire-before-unlink above.
SlotLockTest pins the held-lock case both ways.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 6d007c7 commit 172cfe6
7 files changed
Lines changed: 201 additions & 30 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 | |
|---|---|---|---|
| |||
1658 | 1658 | | |
1659 | 1659 | | |
1660 | 1660 | | |
1661 | | - | |
| 1661 | + | |
1662 | 1662 | | |
1663 | 1663 | | |
1664 | 1664 | | |
| |||
3065 | 3065 | | |
3066 | 3066 | | |
3067 | 3067 | | |
3068 | | - | |
| 3068 | + | |
| 3069 | + | |
3069 | 3070 | | |
3070 | 3071 | | |
3071 | 3072 | | |
| |||
3106 | 3107 | | |
3107 | 3108 | | |
3108 | 3109 | | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
3109 | 3138 | | |
3110 | 3139 | | |
3111 | 3140 | | |
| |||
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
309 | 320 | | |
310 | 321 | | |
311 | 322 | | |
| |||
821 | 832 | | |
822 | 833 | | |
823 | 834 | | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
824 | 839 | | |
825 | 840 | | |
826 | 841 | | |
| |||
1283 | 1298 | | |
1284 | 1299 | | |
1285 | 1300 | | |
1286 | | - | |
| 1301 | + | |
1287 | 1302 | | |
1288 | 1303 | | |
1289 | 1304 | | |
| |||
1325 | 1340 | | |
1326 | 1341 | | |
1327 | 1342 | | |
1328 | | - | |
| 1343 | + | |
1329 | 1344 | | |
1330 | 1345 | | |
1331 | 1346 | | |
| |||
Lines changed: 49 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
290 | 315 | | |
291 | 316 | | |
292 | 317 | | |
| |||
693 | 718 | | |
694 | 719 | | |
695 | 720 | | |
696 | | - | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
697 | 730 | | |
698 | 731 | | |
699 | 732 | | |
| |||
763 | 796 | | |
764 | 797 | | |
765 | 798 | | |
766 | | - | |
| 799 | + | |
767 | 800 | | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
768 | 805 | | |
769 | 806 | | |
770 | 807 | | |
| |||
995 | 1032 | | |
996 | 1033 | | |
997 | 1034 | | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
998 | 1043 | | |
999 | 1044 | | |
1000 | | - | |
| 1045 | + | |
1001 | 1046 | | |
1002 | 1047 | | |
1003 | 1048 | | |
| |||
Lines changed: 17 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
357 | 365 | | |
358 | | - | |
359 | | - | |
360 | | - | |
| 366 | + | |
361 | 367 | | |
362 | | - | |
| 368 | + | |
363 | 369 | | |
364 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
365 | 374 | | |
366 | 375 | | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
372 | 380 | | |
373 | 381 | | |
374 | 382 | | |
| |||
Lines changed: 27 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
172 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
173 | 198 | | |
174 | 199 | | |
175 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
88 | 87 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
95 | 101 | | |
96 | 102 | | |
97 | 103 | | |
| |||
0 commit comments