Commit bcced02
committed
fix(session): claim source on deferred cross-common-dir adopt to prevent double-adopt
The deferred cross-common-dir auto-adopt (DeferSourceRetire) registers the
adopted session in the target and stamps PendingSourceRetire, but left the
source session untouched at prepare time. Two targets that concurrently
discover the same unique live source could both pass the exactly-one-candidate
check, acquire the shared source lock in turn, and each register their own copy
of the same SessionID — a double-adopt, because neither wrote anything the other
would observe. The in-band tombstone the deferral removed had provided that
cross-process mutual exclusion.
Restore it without re-tombstoning at prepare time: under the same source-common-
dir lock, stamp a non-destructive AdoptClaim (target common dir + timestamp) on
the source. It does not end the session, so the source agent keeps checkpointing
(preserving the deferral's abort-safety). A second concurrent adopt re-reads the
source under the lock, observes a fresh claim by a different target, and refuses
(sourceClaimedError -> auto-adopt skips). The candidate discovery filter drops a
claimed source too. post-commit finalize's retire supersedes the claim; a claim
older than adoptRecentWindow is ignored, so an abandoned claim from an aborted
commit self-heals. A re-claim by the same target is idempotent.
Entire-Checkpoint: 01KYX128X8JKV7FH75QR1FV8NW1 parent e15c05d commit bcced02
5 files changed
Lines changed: 399 additions & 10 deletions
File tree
- cmd/entire/cli
- session
- docs/architecture
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
146 | 160 | | |
147 | 161 | | |
148 | 162 | | |
| |||
391 | 405 | | |
392 | 406 | | |
393 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
394 | 424 | | |
395 | 425 | | |
396 | 426 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
174 | 182 | | |
175 | 183 | | |
176 | 184 | | |
| |||
209 | 217 | | |
210 | 218 | | |
211 | 219 | | |
212 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
213 | 240 | | |
214 | 241 | | |
215 | 242 | | |
| |||
276 | 303 | | |
277 | 304 | | |
278 | 305 | | |
| 306 | + | |
| 307 | + | |
279 | 308 | | |
280 | 309 | | |
281 | 310 | | |
| |||
515 | 544 | | |
516 | 545 | | |
517 | 546 | | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
518 | 592 | | |
519 | 593 | | |
520 | 594 | | |
| |||
570 | 644 | | |
571 | 645 | | |
572 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
573 | 650 | | |
574 | 651 | | |
575 | 652 | | |
| |||
631 | 708 | | |
632 | 709 | | |
633 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
634 | 715 | | |
635 | 716 | | |
636 | 717 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
198 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
199 | 208 | | |
200 | 209 | | |
201 | 210 | | |
| |||
396 | 405 | | |
397 | 406 | | |
398 | 407 | | |
399 | | - | |
| 408 | + | |
400 | 409 | | |
401 | 410 | | |
402 | 411 | | |
| |||
456 | 465 | | |
457 | 466 | | |
458 | 467 | | |
459 | | - | |
| 468 | + | |
460 | 469 | | |
461 | 470 | | |
462 | 471 | | |
| |||
468 | 477 | | |
469 | 478 | | |
470 | 479 | | |
| 480 | + | |
471 | 481 | | |
472 | 482 | | |
473 | 483 | | |
| |||
480 | 490 | | |
481 | 491 | | |
482 | 492 | | |
483 | | - | |
| 493 | + | |
484 | 494 | | |
485 | 495 | | |
486 | 496 | | |
487 | 497 | | |
488 | 498 | | |
| 499 | + | |
489 | 500 | | |
490 | 501 | | |
491 | 502 | | |
| |||
494 | 505 | | |
495 | 506 | | |
496 | 507 | | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
497 | 516 | | |
498 | 517 | | |
499 | 518 | | |
| |||
0 commit comments