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.

Keep the authoritative instance in one database

1a9b383890c40885709804293cd3a75e775f06a0 · Keenan Nemetz · 3d ago · parent 12221a79

Keep the authoritative instance in one database

Move the CI queue and the sealed secret rows into instance.db, leaving index.db as the one derived database. Backups now copy the single authoritative file, and the index stays disposable.

Hooks and the SSH front door use the instance database for run credentials and required checks. The admin db commands and documentation now describe one authoritative database plus the derived index.

This was migrated once by hand on the rodent.software instance; there is no migration command and no legacy-layout check in the shipped code.

server/reconcile_test.go +21−5

@@ -2,6 +2,7 @@
2 2 package server
3 3
4 4 import (
5 "database/sql"
5 6 "fmt"
6 7 "io"
7 8 "log/slog"
@@ -51,7 +52,7 @@ func newReconcileHarness(t *testing.T) *reconcileHarness {
51 52 if err != nil {
52 53 t.Fatal(err)
53 54 }
54 st, err := runs.Open(filepath.Join(dir, "runs.db"))
55 st, err := runs.Open(filepath.Join(dir, "instance.db"))
55 56 if err != nil {
56 57 t.Fatal(err)
57 58 }
@@ -150,16 +151,31 @@ func TestReconcileRebuildsAQueueThatWasDeleted(t *testing.T) {
150 151 h.commit(t, "refs/heads/main", testWorkflow)
151 152 h.s.reconcileRefs()
152 153
153 // What `rm data/runs.db` does, including the WAL files SQLite leaves beside it.
154 // What dropping the queue's tables does: the refs still say what is live, so
155 // the work comes back. Dropping them from the instance database is the
156 // production shape now that the queue shares that file with the roster.
154 157 if err := h.runs.Close(); err != nil {
155 158 t.Fatal(err)
156 159 }
157 for _, name := range []string{"runs.db", "runs.db-wal", "runs.db-shm"} {
158 if err := os.Remove(filepath.Join(h.dir, name)); err != nil && !os.IsNotExist(err) {
160 queueDB, err := sql.Open("sqlite", filepath.Join(h.dir, "instance.db"))
161 if err != nil {
162 t.Fatal(err)
163 }
164 for _, table := range []string{
165 "auto_merges", "runner_sessions", "ci_approvals", "ref_cursors",
166 "run_attempt_artifacts", "run_live_steps", "run_steps", "run_attempts",
167 "run_logs", "run_attestations", "run_artifacts", "run_credentials",
168 "run_labels", "runs",
169 } {
170 if _, err := queueDB.Exec("DROP TABLE IF EXISTS " + table); err != nil {
171 queueDB.Close()
159 172 t.Fatal(err)
160 173 }
161 174 }
162 st, err := runs.Open(filepath.Join(h.dir, "runs.db"))
175 if err := queueDB.Close(); err != nil {
176 t.Fatal(err)
177 }
178 st, err := runs.Open(filepath.Join(h.dir, "instance.db"))
163 179 if err != nil {
164 180 t.Fatal(err)
165 181 }