Repository navigation
Commit eb29429
committed
fix(daemon): settings startup survives busy and interrupted writes
Nondeterministic Windows reds came from races on _config.db:
test-windows-guards section_start_status_port / daemon_lifecycle ("the
daemon did not accept the UI configuration"), section_churn_stability
("could not load saved runtime settings"), the windows-2025 release
smoke whose `--ui=true --port` server exited about 5 s after start
(Phase 15, read as "no embedded UI assets"), and section_crash_recovery
("the stale daemon state never cleared").
- Every _config.db connection now waits out a committing writer
(cbm_runtime_settings_wait_for_writers: one busy handler, logs
config_db.busy_wait once per busy wait, a 3 s bound for a wedged
holder). Startup's 50 ms window let a daemon's routine commit end
unrelated CLI starts; cbm_config_open and the UI load had no wait at
all, so a concurrent commit failed the daemon's UI save and made the
load keep defaults.
- A process killed mid-write (crash, taskkill /F, power loss) left a hot
rollback journal that the read-only settings reads cannot roll back
(SQLITE_READONLY_ROLLBACK). Every later command then failed with
"could not load saved runtime settings", permanently. Settings startup
and the UI load now recover once through a read-write open that rolls
the interrupted write back (config_db.hot_journal_recovered); a failed
recovery is reported with the journal path and stays fatal.
- write_value no longer rewrites an unchanged value. The upsert fired the
revision trigger, so every `daemon start` on a UI build committed and
locked readers out although nothing changed.
- `daemon start` and the stdio server wait for the set_context and
set_ui_config replies within their startup budget instead of the 1 s
probe budget (MAIN_CONNECT_TIMEOUT_MS) that decided the command
whenever the daemon's save ran long.
Tests, red on 8df0639 and green here:
- runtime_settings suite: three single-threaded lock tests (a log sink
commits the held lock when the waiter logs config_db.busy_wait, so no
test depends on a duration) and two hot-journal tests (a portable
fixture snapshots the database and its journal mid-transaction and
checks the journal is hot before the code under test runs).
- tests/windows/test_daemon_stability.py: new section
start_port_waits_for_settings_writer holds the lock against a real
`daemon start --port` and releases it on events; the crash section
now prints the status output it saw.
Signed-off-by: Martin Vogel <[email protected]>1 parent 8df0639 commit eb29429
6 files changed
Lines changed: 469 additions & 36 deletions
File tree
- src
- cli
- tests
- windows
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
7409 | 7410 | | |
7410 | 7411 | | |
7411 | 7412 | | |
| 7413 | + | |
| 7414 | + | |
| 7415 | + | |
7412 | 7416 | | |
7413 | 7417 | | |
7414 | 7418 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
206 | 232 | | |
207 | 233 | | |
208 | 234 | | |
| |||
234 | 260 | | |
235 | 261 | | |
236 | 262 | | |
237 | | - | |
| 263 | + | |
238 | 264 | | |
239 | 265 | | |
240 | 266 | | |
| |||
442 | 468 | | |
443 | 469 | | |
444 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
445 | 530 | | |
446 | 531 | | |
447 | 532 | | |
| |||
453 | 538 | | |
454 | 539 | | |
455 | 540 | | |
456 | | - | |
457 | | - | |
458 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
459 | 546 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | 547 | | |
471 | 548 | | |
472 | 549 | | |
| |||
640 | 717 | | |
641 | 718 | | |
642 | 719 | | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
643 | 723 | | |
644 | 724 | | |
645 | 725 | | |
646 | 726 | | |
647 | | - | |
| 727 | + | |
648 | 728 | | |
649 | 729 | | |
650 | 730 | | |
651 | | - | |
| 731 | + | |
652 | 732 | | |
653 | 733 | | |
654 | 734 | | |
| |||
759 | 839 | | |
760 | 840 | | |
761 | 841 | | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
766 | 847 | | |
767 | | - | |
768 | | - | |
769 | 848 | | |
770 | 849 | | |
771 | 850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2483 | 2483 | | |
2484 | 2484 | | |
2485 | 2485 | | |
2486 | | - | |
| 2486 | + | |
2487 | 2487 | | |
2488 | 2488 | | |
2489 | 2489 | | |
2490 | 2490 | | |
2491 | 2491 | | |
2492 | 2492 | | |
2493 | 2493 | | |
2494 | | - | |
2495 | | - | |
2496 | | - | |
| 2494 | + | |
| 2495 | + | |
2497 | 2496 | | |
2498 | 2497 | | |
2499 | 2498 | | |
| |||
2712 | 2711 | | |
2713 | 2712 | | |
2714 | 2713 | | |
2715 | | - | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
2716 | 2721 | | |
2717 | 2722 | | |
2718 | 2723 | | |
| |||
2722 | 2727 | | |
2723 | 2728 | | |
2724 | 2729 | | |
2725 | | - | |
| 2730 | + | |
2726 | 2731 | | |
2727 | | - | |
| 2732 | + | |
| 2733 | + | |
2728 | 2734 | | |
2729 | 2735 | | |
2730 | 2736 | | |
2731 | | - | |
| 2737 | + | |
2732 | 2738 | | |
2733 | 2739 | | |
2734 | 2740 | | |
| |||
3371 | 3377 | | |
3372 | 3378 | | |
3373 | 3379 | | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
3374 | 3384 | | |
3375 | 3385 | | |
3376 | | - | |
| 3386 | + | |
3377 | 3387 | | |
3378 | 3388 | | |
3379 | 3389 | | |
| |||
3391 | 3401 | | |
3392 | 3402 | | |
3393 | 3403 | | |
3394 | | - | |
3395 | | - | |
3396 | | - | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
3397 | 3408 | | |
3398 | 3409 | | |
3399 | 3410 | | |
| |||
0 commit comments