This repository was archived by the owner on Jan 12, 2026. It is now read-only.
Commit 61ab24e
Implement TaskGuard RAII pattern and fix Block-STM livelock (#7)
This commit includes two major improvements to the Block-STM parallel execution engine:
1. **TaskGuard RAII Pattern**: Refactored `num_active_tasks` tracking to use a RAII guard pattern.
- TaskGuard automatically increments counter on creation and decrements on drop
- Eliminates manual increment/decrement tracking that was error-prone
- Guards are created only when tasks are successfully acquired
- Guards can be reused when finish_execution/finish_validation return follow-up tasks
2. **Fixed MVHashMap Livelock**: Resolved infinite retry loop in parallel execution.
- Root cause: When converting writes to estimates during validation abort, old write
entries weren't removed from the MVHashMap
- This caused subsequent reads to get Estimate values instead of actual Write values
- Transactions would infinitely retry when `add_dependency()` returned false
- Fix: Remove old write entries before updating `last_written_locations` in
`convert_writes_to_estimates()`
Additional changes:
- Removed debug logging added during troubleshooting
- Updated all scheduler methods to return `Option<(Task, TaskGuard)>` tuples
- Updated executor to destructure and pass guards through the task lifecycle
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 3c6d943 commit 61ab24e
5 files changed
Lines changed: 287 additions & 177 deletions
File tree
- crates/op-rbuilder/src
- block_stm
- builders
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
164 | 168 | | |
165 | 169 | | |
166 | 170 | | |
167 | 171 | | |
168 | 172 | | |
169 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
170 | 176 | | |
171 | 177 | | |
172 | 178 | | |
| |||
176 | 182 | | |
177 | 183 | | |
178 | 184 | | |
179 | | - | |
| 185 | + | |
180 | 186 | | |
181 | | - | |
| 187 | + | |
182 | 188 | | |
183 | 189 | | |
184 | 190 | | |
185 | 191 | | |
186 | 192 | | |
187 | | - | |
188 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
| |||
221 | 232 | | |
222 | 233 | | |
223 | 234 | | |
224 | | - | |
225 | 235 | | |
226 | 236 | | |
227 | 237 | | |
| |||
381 | 391 | | |
382 | 392 | | |
383 | 393 | | |
384 | | - | |
385 | | - | |
386 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
387 | 397 | | |
388 | 398 | | |
389 | 399 | | |
| |||
415 | 425 | | |
416 | 426 | | |
417 | 427 | | |
418 | | - | |
419 | 428 | | |
420 | 429 | | |
421 | 430 | | |
422 | 431 | | |
423 | 432 | | |
424 | 433 | | |
425 | 434 | | |
426 | | - | |
| 435 | + | |
427 | 436 | | |
428 | 437 | | |
429 | 438 | | |
| |||
433 | 442 | | |
434 | 443 | | |
435 | 444 | | |
436 | | - | |
| 445 | + | |
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
| |||
465 | 474 | | |
466 | 475 | | |
467 | 476 | | |
468 | | - | |
| 477 | + | |
469 | 478 | | |
470 | 479 | | |
471 | 480 | | |
| |||
477 | 486 | | |
478 | 487 | | |
479 | 488 | | |
480 | | - | |
| 489 | + | |
481 | 490 | | |
482 | 491 | | |
483 | 492 | | |
484 | 493 | | |
485 | 494 | | |
486 | | - | |
| 495 | + | |
487 | 496 | | |
488 | 497 | | |
489 | 498 | | |
| |||
527 | 536 | | |
528 | 537 | | |
529 | 538 | | |
530 | | - | |
| 539 | + | |
531 | 540 | | |
532 | 541 | | |
533 | 542 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
| |||
0 commit comments