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

forge/secret/secret.go +2−5

@@ -32,11 +32,10 @@ import (
32 32 "time"
33 33 "unicode/utf8"
34 34
35 _ "modernc.org/sqlite"
36
37 35 "rodent.software/vole/ci"
38 36 "rodent.software/vole/internal/audit"
39 37 "rodent.software/vole/internal/secure"
38 "rodent.software/vole/internal/sqlstore"
40 39 )
41 40
42 41 const (
@@ -97,12 +96,10 @@ func Open(dbPath, keyPath string) (*Store, error) {
97 96 if err != nil {
98 97 return nil, err
99 98 }
100 dsn := dbPath + "?_busy_timeout=5000&_journal_mode=WAL"
101 db, err := sql.Open("sqlite", dsn)
99 db, err := sqlstore.Open(dbPath, sqlstore.Options{MaxConns: 2})
102 100 if err != nil {
103 101 return nil, err
104 102 }
105 db.SetMaxOpenConns(2)
106 103 if _, err := db.Exec(`
107 104 CREATE TABLE IF NOT EXISTS secrets (
108 105 repo_id TEXT NOT NULL,