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/index/index.go +2−5

@@ -11,9 +11,8 @@ import (
11 11 "fmt"
12 12 "time"
13 13
14 _ "modernc.org/sqlite"
15
16 14 "rodent.software/vole/forge/repo"
15 "rodent.software/vole/internal/sqlstore"
17 16 )
18 17
19 18 type Entry struct {
@@ -38,12 +37,10 @@ type Entry struct {
38 37 type Store struct{ db *sql.DB }
39 38
40 39 func Open(path string) (*Store, error) {
41 dsn := path + "?_busy_timeout=5000&_journal_mode=WAL"
42 db, err := sql.Open("sqlite", dsn)
40 db, err := sqlstore.Open(path, sqlstore.Options{MaxConns: 4})
43 41 if err != nil {
44 42 return nil, err
45 43 }
46 db.SetMaxOpenConns(4)
47 44 s := &Store{db: db}
48 45 if _, err := db.Exec(`
49 46 CREATE TABLE IF NOT EXISTS repos (