vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Give the instance database one write policy
8f6548a6249e86bfb4741a85cc6ca7efe8b3a064 · Keenan Nemetz · 3d ago · parent 1eac8552
Give the instance database one write policy instance.db has one writer per file, and the server, the push hook, and sshd's key command all open it. Each store picked its own pragmas, so a transaction that read and then wrote could be refused with SQLITE_BUSY without the busy timeout applying. And the push hook opened every store with the writer open, which ran each schema inside a push: runs.Open dropped and rebuilt the runs_once index on every call, over a run table that is never pruned, while the server might be committing a lease. Open every file through internal/sqlstore instead: WAL, synchronous=NORMAL, and immediate write transactions, with a read-only mode for the processes that only read. The hook and sshd's key lookup use that read-only mode, so a push can no longer write a schema. The queue's shape is applied once per database and recorded in a schema_versions row, so reopening it does no DDL and an old unversioned queue still upgrades. Write transactions that only touch the database retry a lock conflict instead of failing the operation. Refs #398
server/hook/hook_test.go +28
| @@ -11,7 +11,9 @@ import ( | |||
| 11 | 11 | ||
| 12 | 12 | "rodent.software/vole/ci/runs" | |
| 13 | 13 | "rodent.software/vole/core/git" | |
| 14 | "rodent.software/vole/core/lfs" | ||
| 14 | 15 | "rodent.software/vole/forge/access" | |
| 16 | "rodent.software/vole/forge/channel" | ||
| 15 | 17 | "rodent.software/vole/forge/identity" | |
| 16 | 18 | "rodent.software/vole/forge/index" | |
| 17 | 19 | "rodent.software/vole/forge/repo" | |
| @@ -73,8 +75,34 @@ func newFixture(t *testing.T, blob string) *fixture { | |||
| 73 | 75 | // roster and the access rules, which is what the server has. | |
| 74 | 76 | func testInstanceDB(root string) string { return filepath.Join(root, "instance.db") } | |
| 75 | 77 | ||
| 78 | // testSchema creates the tables the push gate reads. A real instance gets them | ||
| 79 | // from forge.Open; the hook only reads them now, so the fixture has to build the | ||
| 80 | // shape the server would have before the first push arrives. | ||
| 81 | func testSchema(t *testing.T, root string) { | ||
| 82 | t.Helper() | ||
| 83 | path := testInstanceDB(root) | ||
| 84 | if err := identity.Init(path); err != nil { | ||
| 85 | t.Fatal(err) | ||
| 86 | } | ||
| 87 | locks, err := lfs.OpenLocks(path) | ||
| 88 | if err != nil { | ||
| 89 | t.Fatal(err) | ||
| 90 | } | ||
| 91 | if err := locks.Close(); err != nil { | ||
| 92 | t.Fatal(err) | ||
| 93 | } | ||
| 94 | channels, err := channel.Open(path) | ||
| 95 | if err != nil { | ||
| 96 | t.Fatal(err) | ||
| 97 | } | ||
| 98 | if err := channels.Close(); err != nil { | ||
| 99 | t.Fatal(err) | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 76 | 103 | func testACLs(t *testing.T, root string) *access.Store { | |
| 77 | 104 | t.Helper() | |
| 105 | testSchema(t, root) | ||
| 78 | 106 | acls, err := access.Open(testInstanceDB(root)) | |
| 79 | 107 | if err != nil { | |
| 80 | 108 | t.Fatal(err) | |