Commit 76db2e0
committed
Avoid double directory scan when registering a recovered SF ring
SegmentRing.openExisting walked every slot-directory entry to recover
segments, then SegmentManager.register immediately re-enumerated the
same directory (scanMaxGeneration) to seed the spare file-generation
counter, re-allocating a name String plus substring per entry.
The recovery scan now tracks the maximum sf-<gen:016x>.sfa generation
it observes and carries it on the returned ring
(maxRecoveredFileGeneration); register() uses that value and only
falls back to the legacy directory rescan for rings that were not
built by recovery (FILE_GENERATION_UNKNOWN: fresh start, memory mode,
tests), so behavior for non-recovered rings is unchanged.
Safety properties, pinned by SegmentRingRecoveryGenerationTest:
- the maximum covers every scanned entry, including empty leftovers
recovery unlinks and corrupt files it quarantines, so a generation
is never reused even for files gone by registration time;
- name->generation parsing is a single shared helper
(SegmentRing.parseFileGeneration) used by both the recovery scan
and the fallback rescan, so the two can never disagree;
- freshly minted spares always land strictly above everything on
disk -- never at a name whose truncating openCleanRW would destroy
a recovered segment.
The carried value cannot be stale for its intended (first)
registration: recovery and register run on one thread under the
engine slot lock, and no spare can be minted into the slot before
register wires the ring up. Same-manager re-registration stays safe
because advanceFileGeneration only ratchets upward.1 parent e2fc980 commit 76db2e0
3 files changed
Lines changed: 378 additions & 13 deletions
File tree
- core/src
- main/java/io/questdb/client/cutlass/qwp/client/sf/cursor
- test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor
Lines changed: 26 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
422 | 440 | | |
423 | 441 | | |
424 | 442 | | |
| |||
501 | 519 | | |
502 | 520 | | |
503 | 521 | | |
504 | | - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
505 | 527 | | |
506 | 528 | | |
507 | 529 | | |
| |||
518 | 540 | | |
519 | 541 | | |
520 | 542 | | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
| 543 | + | |
| 544 | + | |
532 | 545 | | |
533 | 546 | | |
534 | 547 | | |
| |||
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
| |||
106 | 114 | | |
107 | 115 | | |
108 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
109 | 122 | | |
110 | 123 | | |
111 | 124 | | |
| |||
170 | 183 | | |
171 | 184 | | |
172 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
173 | 191 | | |
174 | 192 | | |
175 | 193 | | |
| |||
196 | 214 | | |
197 | 215 | | |
198 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
199 | 227 | | |
200 | 228 | | |
201 | 229 | | |
| |||
355 | 383 | | |
356 | 384 | | |
357 | 385 | | |
| 386 | + | |
358 | 387 | | |
359 | 388 | | |
360 | 389 | | |
| |||
374 | 403 | | |
375 | 404 | | |
376 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
377 | 431 | | |
378 | 432 | | |
379 | 433 | | |
| |||
643 | 697 | | |
644 | 698 | | |
645 | 699 | | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
646 | 722 | | |
647 | 723 | | |
648 | 724 | | |
| |||
0 commit comments