Commit cc4a68f
feat(ilp): cursor SF -- on-disk recovery + maxTotalBytes cap
Two pre-wiring additions on the cursor side that the upcoming
WebSocketSendQueue replacement will need.
1. SegmentRing.openExisting(sfDir, maxBytesPerSegment)
Walks *.sfa files in the directory, opens each via
MmapSegment.openExisting (which already validates header + scans
torn tails), arranges by baseSeq, and returns a ring with the
newest as active and the rest as sealed. Validates that the
recovered segments form a contiguous FSN range -- a gap signals
manual deletion or partial-write damage and aborts recovery
rather than silently producing duplicate / missing FSNs after
restart. Stray .sfa files with bad headers are skipped (logged-
then-ignored), not fatal.
2. SegmentManager maxTotalBytes cap
Manager tracks total bytes it has provisioned across all rings
it serves. When provisioning a hot spare would exceed the cap,
the manager skips the install and the requesting ring stays in
BACKPRESSURE_NO_SPARE until ACK-driven trim frees space. Default
is UNLIMITED_TOTAL_BYTES (no behavioural change for existing
callers). Disk-full state is logged at WARN, throttled to once
per 30s so a sustained-full state doesn't drown the log. Cap is
approximate -- it counts only manager-provisioned segments, not
the engine's initial active per ring (so the effective on-disk
cap is maxTotalBytes + (rings * segmentSizeBytes)). Acceptable
for a runaway-growth guard; documented in the constructor.
Also makes SegmentRing.sealedSegments mutation thread-safe via a
synchronized snapshot path that the I/O loop will use, and marks
SegmentRing.active volatile so cross-thread rotation publication
is correct without a lock.
10 new tests across SegmentRingTest + SegmentManagerTest covering:
recovery happy path, FSN-gap detection, bad-magic skip, cap blocks
provisioning, cap is released by ACK-driven trim. All 2020 tests in
the suite pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 49f1683 commit cc4a68f
4 files changed
Lines changed: 385 additions & 20 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: 76 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
73 | 83 | | |
74 | | - | |
| 84 | + | |
75 | 85 | | |
76 | 86 | | |
77 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
78 | 114 | | |
79 | 115 | | |
80 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
81 | 122 | | |
82 | 123 | | |
| 124 | + | |
83 | 125 | | |
84 | 126 | | |
85 | 127 | | |
| |||
136 | 178 | | |
137 | 179 | | |
138 | 180 | | |
139 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
140 | 187 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
148 | 199 | | |
149 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
150 | 213 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 214 | + | |
154 | 215 | | |
155 | | - | |
156 | | - | |
157 | 216 | | |
158 | 217 | | |
159 | 218 | | |
| |||
163 | 222 | | |
164 | 223 | | |
165 | 224 | | |
| 225 | + | |
166 | 226 | | |
167 | 227 | | |
168 | 228 | | |
169 | 229 | | |
170 | 230 | | |
| 231 | + | |
171 | 232 | | |
172 | 233 | | |
173 | 234 | | |
| |||
Lines changed: 152 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 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 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
94 | 202 | | |
95 | 203 | | |
96 | 204 | | |
| |||
137 | 245 | | |
138 | 246 | | |
139 | 247 | | |
140 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
141 | 254 | | |
142 | 255 | | |
143 | 256 | | |
| |||
179 | 292 | | |
180 | 293 | | |
181 | 294 | | |
182 | | - | |
| 295 | + | |
183 | 296 | | |
184 | 297 | | |
185 | 298 | | |
186 | 299 | | |
| 300 | + | |
| 301 | + | |
187 | 302 | | |
188 | 303 | | |
189 | 304 | | |
| |||
204 | 319 | | |
205 | 320 | | |
206 | 321 | | |
207 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
208 | 328 | | |
209 | 329 | | |
210 | 330 | | |
211 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
212 | 360 | | |
213 | 361 | | |
214 | 362 | | |
| |||
0 commit comments