Expand description
Database schema, migrations and queries of schedr (SQLite and Postgres).
All persistent state lives in the database (see archive/PROJECT.md, State storage). The schema
is upgraded by schedr db migrate; the roles refuse to start against an outdated schema.
Re-exports§
pub use backend::Backend;pub use backend::UnsupportedUrl;pub use backend::database_place;pub use backend::redact_password;pub use database::Database;pub use database::DbError;pub use database::Pool;pub use status::SchemaStatus;
Modules§
- attempts
- Attempts: one try of a task instance on a worker.
- backend
- The two database backends and their migrations.
- backfills
- Backfills (decisions 363, 364, 400-404): a run per fire time of a range that has no successful, queued or running run (or every fire time), created together with the backfill, oldest first behind the other kinds of runs. The backfill’s ID is the command’s that asked for it.
- changes
- What changed, for the UI’s live pages (see archive/PROJECT.md, Web UI: 34A): which run, which DAG, or the workers. Only what changed, never the new state: the UI reads that from the API.
- commands
- Command rows: written by the webserver, applied by the master, kept as the audit trail.
- dags
- The DAG catalog’s storage: parse results with their files, DAGs and DAG versions.
- database
- A connection pool to the schedr database, and schema migration and checks.
- instances
- Task instances of runs: created when a run starts, moved forward by the master, and the run’s result when they have all finished.
- lease
- The master’s lease: one master per database (see archive/PROJECT.md, Components and roles:
production path). A one-row table, taken and renewed by one statement each, timed by the
database’s clock, so it needs no session state: it works through any connection
pooler (
PgBouncerin transaction pooling too), and on SQLite. - named_
events - Events posted through the API (decision 354):
POST /api/v1/events. Each post is an event of its own, a repeat of a name and key too; a trigger starts a run per key it hasn’t seen, and a step waiting in a run matches one posted since its run started. - nodes
- A deployment’s nodes, for the Deployments page (decisions 121-123): each master (leader or standby) heartbeating its row, and each worker’s master, process and configuration.
- notifications
- Notifications to deliver (decision 410): the outbox. A notification is written in the transaction that records its event; the master’s sender delivers it and deletes it, or retries it later, or gives up on it.
- probe
- The round’s probe (decision 485): one statement a tick answering, for each read a master’s
round makes, whether that read would find anything. Inside
Database::in_round, a read whose check said no returns nothing without going to the database; reads anywhere else (a worker’s turn, the API) are never skipped. - reads
- What the webserver reads: runs, their task instances and attempts, as shown to people.
- retention
- Retention (decisions 430-435): what the master’s retention job deletes once
[retention]no longer keeps it, a batch per transaction (runs and outputs one DAG at a time). Never an unfinished run, nor one something unfinished reads, nor what a DAG still needs (seeKEPT), unless the DAG was removed long enough ago; a removed DAG then goes with its last run. - run_of
- What a
wait_for(RunOf(...))step reads of another DAG’s runs (decision 353). - runs
- DAG runs: creating them, and what the scheduler reads to decide on new ones.
- samples
- Samples of each schedr process (decision 464): one a minute (step 60), and 15-minute averages and peaks of them (step 900), for the Metrics page’s charts.
- secrets
- The
dbsecret storage (standalone; see archive/PROJECT.md, Secret storage): one row per secret path, like a Vault KV v2 secret, itsdataa JSON object of key to value. Each value is encrypted with XChaCha20-Poly1305 underSCHEDR_SECRET_KEY, bound to itspath#key(the associated data), so a value can’t be moved to another key or path; paths and key names stay readable, so listing needs no key. A dump, a backup or someone reading the database sees no value. - status
- Whether a database’s schema fits this build of schedr.
- strikes
- Wait steps that keep getting their host killed (decision 338): counted here, switched off after so many in a row, on again with new code or by hand.
- task_
flow - The Metrics page’s throughput and start latency (decision 494), read from the attempts
table: how many attempts ended in each bucket, by how they ended, and how long the ones
started in it took from their assignment to their start (
started_at, the worker’s start in master time, decision 490), as p50 and p95. Each read is one statement over an index on the time it buckets by. - task_
memory - A task’s peak memory over its attempts (decision 467): the task panel’s chart of its last attempts and the DAG page’s p95 peaks, read from the attempts table.
- triggers
- Event-triggered DAGs’ triggers and what they found (M4.11b): each new key starts a run, and the last key acted on is the bookmark a trigger starts again from.
- workers
- The worker registry: every worker the master has seen, with its state, kept after it is gone (offline or lost) so its logs can still be found (see archive/PROJECT.md, Worker lifecycle).
Functions§
- db_time
- A time as stored:
2026-10-21T08:00:00.000000Z(microseconds, as Postgres keeps them).