Repository navigation
Commit db720a5
storage: serialize every operation on the shared-cache :memory: store
`vgi-fixture-http` failed 69 cases of the upstream integration suite with
`sqlite3.OperationalError: database table is locked`, direct to the worker.
The shared-cache in-memory store serialized only its writers. Shared-cache
locks are per table and conflict both ways -- a writer cannot modify a table
another connection is reading, a reader cannot read one with another
connection's uncommitted write -- and either is SQLITE_LOCKED, which the busy
handler never retries. So a `state_scan` overlapping an `execution_clear`
failed exactly as two pops had before a550612.
It stayed hidden because the fixture never really ran on `:memory:`: until
94df3e3, `import vgi` resolved `Function.storage` before the fixture's `main()`
could set `VGI_WORKER_SQLITE_PATH=:memory:`, so it used the shared file store.
Making resolution lazy (0.34.1) let the setting apply and exposed the bug.
- Every public FunctionStorageSqlite operation now goes through the lock
(renamed `_op_guard`). Derived from the class rather than listed: the hand-
written writer list is how the four readers were missed. `close` is the only
exclusion. Reads fetch eagerly, so no statement outlives the guard.
- `_DefaultStorageDescriptor` resolves once under a lock. With resolution lazy,
first use is a request, and concurrent first requests each built a store --
for `:memory:`, separate databases, so state written through one was
invisible through the other.
Tests (all three failed before): 8 threads of mixed reads and writes on one
scope; every public operation is guarded; 8 concurrent first uses build one
store. Measured: the upstream suite takes 150s on the fixed in-memory store vs
152s on a file store, and passes in full (10,700 assertions) on both.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 5b5193f commit db720a5
3 files changed
Lines changed: 178 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 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 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
81 | 90 | | |
82 | 91 | | |
83 | 92 | | |
| 93 | + | |
84 | 94 | | |
85 | 95 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
89 | 103 | | |
90 | 104 | | |
91 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
944 | 945 | | |
945 | 946 | | |
946 | 947 | | |
947 | | - | |
948 | | - | |
949 | | - | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
950 | 951 | | |
951 | 952 | | |
952 | 953 | | |
| |||
986 | 987 | | |
987 | 988 | | |
988 | 989 | | |
989 | | - | |
990 | | - | |
| 990 | + | |
| 991 | + | |
991 | 992 | | |
992 | 993 | | |
993 | 994 | | |
| |||
1008 | 1009 | | |
1009 | 1010 | | |
1010 | 1011 | | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
1011 | 1026 | | |
1012 | | - | |
| 1027 | + | |
1013 | 1028 | | |
1014 | 1029 | | |
1015 | | - | |
| 1030 | + | |
1016 | 1031 | | |
1017 | 1032 | | |
1018 | 1033 | | |
| |||
1477 | 1492 | | |
1478 | 1493 | | |
1479 | 1494 | | |
1480 | | - | |
1481 | | - | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
1482 | 1500 | | |
1483 | | - | |
1484 | | - | |
1485 | | - | |
1486 | | - | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
1487 | 1509 | | |
1488 | 1510 | | |
1489 | 1511 | | |
1490 | 1512 | | |
1491 | 1513 | | |
1492 | | - | |
| 1514 | + | |
1493 | 1515 | | |
1494 | 1516 | | |
1495 | 1517 | | |
1496 | 1518 | | |
1497 | | - | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
1511 | 1523 | | |
1512 | 1524 | | |
1513 | | - | |
| 1525 | + | |
1514 | 1526 | | |
1515 | 1527 | | |
1516 | 1528 | | |
| |||
0 commit comments