Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

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/ssh/sshserver_test.go +15

@@ -23,6 +23,7 @@ import (
23 23 "rodent.software/vole/ci/runs"
24 24 "rodent.software/vole/core/lfs"
25 25 "rodent.software/vole/forge/access"
26 "rodent.software/vole/forge/channel"
26 27 "rodent.software/vole/forge/identity"
27 28 "rodent.software/vole/forge/repo"
28 29 )
@@ -107,6 +108,20 @@ func newRecordingHarness(t *testing.T, tweak func(*Config)) (*harness, *recordin
107 108 if err := identity.Init(instanceDB); err != nil {
108 109 t.Fatal(err)
109 110 }
111 // A push gate reads the roster, the access rules, the lock table and the
112 // channel table, which forge.Open creates in a real instance. This harness keeps
113 // the queue in its own file, so it creates the rest of the shape explicitly:
114 // the hook opens them read-only and must not be the reason a schema appears.
115 locks, err := lfs.OpenLocks(instanceDB)
116 if err != nil {
117 t.Fatal(err)
118 }
119 t.Cleanup(func() { locks.Close() })
120 channels, err := channel.Open(instanceDB)
121 if err != nil {
122 t.Fatal(err)
123 }
124 t.Cleanup(func() { channels.Close() })
110 125 ident, err := identity.Open(instanceDB)
111 126 if err != nil {
112 127 t.Fatal(err)