Skip to content

The databases

The server keeps its state in six SQLite files in the state root. This page names each file, says what it is for, and lists the tables in it: what one row holds, why the table exists, and how long a row stays. Read it to know what a backup carries, what a delete costs, and where a piece of data lives.

You never write these files by hand. Every change goes through a command of the server or of the tadoru tool. Backup and restore says how the files travel, and The query log says what the log holds.

Each file has its own database, so a busy or damaged one cannot stop another. A failed query log does not stop DNS.

Every file except owner.sqlite uses WAL (write-ahead logging), so a reader does not block the writer. Each of them has the side files -wal and -shm while the server runs, and mode 0600. Each of them has a table schema_version. It holds the number of each step that made the schema. A build refuses a file with a newer schema than its own.

synchronous says how much a power cut can lose. FULL flushes on every commit, so a committed write survives. NORMAL leaves the flush to the operating system, so a power cut can lose the last rows.

File What it is for tadoru backup tadoru restore Secret Journal and sync Delete zeroes
owner.sqlite The lock that says which process owns the state root No Does not touch it No Rollback journal Holds no data
control.sqlite The history of changes and the audit of the serial witness Yes Replaces it with the copy No WAL, FULL Cells in pages still in use
serials.sqlite The serial witness of the zones of this node A copy, in witness-copy/ Merges the copy into the file No WAL, FULL Cells in pages still in use
record_times.sqlite When each record of a zone last changed on this node No Deletes it and its side files No WAL, NORMAL Cells in pages still in use
auth.sqlite The accounts, the API tokens and the sessions Yes Replaces it with the copy Yes WAL, FULL Cells and the pages it frees
telemetry.sqlite The query log and the hourly statistics Only with --include-telemetry Replaces it where the archive has it No WAL, NORMAL Cells in pages still in use

A secret file holds what proves a person. auth.sqlite keeps a verifier for each password: an argon2id hash with its own salt. It keeps a SHA-256 hash of each token and of each session cookie. The forgery token of a session is in the file in plain text, so the file is secret. The backup encrypts the file when you give it a passphrase. telemetry.sqlite is not secret, but it can hold names and client addresses. The query log says how to limit that.

What a delete leaves differs by file. Only auth.sqlite zeroes the pages that a delete frees. It also tries to cut its -wal after each delete of a verifier or a session. A reader or a failure can block the cut. Older copies then stay in the -wal, and the server retries at its start and every minute. The other four zero only the cells inside pages that stay in use. A freed page, an overflow page and an old frame of the -wal keep their bytes until the space is reused. A redaction of the query log scrubs its free pages and cuts its -wal (The query log says how). In every file, the unused space inside a page that stays in use can keep a copy of old bytes until the file is rewritten. tadoru rewrite, with the server stopped, writes each of the five files with data again, with every row and none of those copies (The command line says how). The file then has a new inode, and its next open puts it back in WAL mode.

These names can appear next to a file. The server and tadoru rewrite make them.

Name What it is
<file>-wal, -shm The write-ahead log and its index. They are part of the database. Never delete them by hand: a -wal can hold committed writes that the main file lacks. SQLite removes both at a clean close.
owner.sqlite-journal The rollback journal of owner.sqlite, while the lock is held.
<file>.damaged A file that a start found damaged and moved aside, kept for a person. A second one is <file>.damaged.2. The server never reads it.
<file>.new The new file that a start makes after a loss, before it renames it into place. A start deletes one it finds.
<file>.rewrite The copy of a file that tadoru rewrite writes and checks before it takes the name of the file, with its -journal for a moment. A copy of auth.sqlite is secret. The next rewrite and the next start delete one that a rewrite left.
<file>.rewrite-aside-... For a moment while tadoru rewrite puts its copy in place: the copy, or the file it replaced. The next rewrite and the next start delete it, or put it back where another program wrote that file. Where they cannot prove which file holds the rows, both stay, a rewrite refuses the store, and the server does not start until you keep one.
serials.sqlite.aside The name that a start picks for a serial witness it moves aside. A start after a crash reads it to finish the move, so leave it.

A damaged serials.sqlite or record_times.sqlite moves aside and a new one takes its place. A damaged control.sqlite or auth.sqlite stops the start with a message, because those two cannot be rebuilt.

This file is a lock and holds no table. It uses a rollback journal, not WAL. The first server to start takes a write lock on it and holds the lock while it runs. A second server, or a command that needs the state root alone, finds the lock taken and says so. The operating system releases the lock at the end of the process. A crash leaves nothing to clean up.

If you delete it, nothing is lost. The next start makes it again.

This file is the ledger of the server. It records every command that changed something, in the order it ran, with the configuration revision it made. It also holds the marks that let a start tell a journal that was lost from one that was never made. Dynamic updates, ACME (Automatic Certificate Management Environment, RFC 8555) and the serial witness write to it too.

A backup copies it, and a restore replaces it whole. If you delete it, the history goes and a restore is the way back. A lost witness_since reads as a first start. A lost audit row of the serial witness settles its entry in serials.sqlite as unknown.

Table What one row stores Why it exists How long a row stays
schema_version The number of one step that made the schema Tells a start which steps still must run Forever
commands One command: its id, its origin, who sent it, a summary, its state, a problem text, the generation it made, and the times it was received and finished The audit of every change, and the record that a start reads to settle a command that a crash cut short A command that made a revision stays. A finished command of a dynamic update, ACME, aging, a serial witness move or an expiry sweep that made none goes 7 days or more after it ends. A record change through the API (origin api, no revision) is eligible after 90 days from its receipt, or when more than 200,000 stand, oldest first. It stays while a journal still needs it, while it is received, or while a record_changes row names it. An unchanged change goes with its record_changes row, after 24 hours
journal_places The journal and the sequence number where a command wrote its transaction Lets a start find out which command wrote which frame of a zone journal Goes with its command
journal_highest The highest sequence number of one journal A new write never takes a number that an old, pruned command used Forever
journal_first_revision The revision that was served when a journal was made Marks which journals carry history of the parent revision Forever
journals One journal id with its zone, the base and checksum of its header, whether it is a remake, and whether its file is in place Lets a start tell a lost journal from one that was never made Forever
journal_links A link from one journal to the journal that it replaces Keeps the chain of remade and cut journals Forever
command_zones The zones that one command touched Lets the audit ask which commands touched a zone, for a command that makes no revision Goes with its command
acme_records The ACME record of one command: add or remove, the zone, the owner, the value and whether it is held Makes sure a challenge record is removed, and not left behind, after a crash An add stays until the removal of it settles. The row goes with its command
record_changes The stored answer of one change of records through the API, by the key of its caller, with the answer the route sent, at most 16 KiB Lets a repeat of the same request get the first answer and never apply twice 24 hours after it settles. A pending row stays until it settles. A row of an earlier era goes at the next prune after a restore. A settled row whose command stayed received waits for the next start
record_change_era One row: the number of the current era of record changes A restore moves the era, so a key from before the restore cannot match a row of another history One row, forever
record_audit One row: the count of commands of record changes Triggers keep the count in step with the commands whose id starts with records:. They stop anyone from adding or deleting the row, so the audit prune has the count One row, forever
witness_commands The audit row of one accept, raise or reset of the serial witness Records who changed the witness, because an operator runs those commands by hand Forever. Nothing prunes it
witness_command_rows One apex of one witness command: its serial range before and after, and the EXPIRE and the quarantine it states Holds the whole intent of the command, so a crash between the two files settles correctly Goes with its command row, so forever
witness_since One row: the time of the first start that made the serial witness A mark with no file of the witness means a lost witness One row, forever
freeze_statements One tadoru zone journal settle-freeze statement: the zone, the journal and its sequence, whether the journal read whole or was gone, not-frozen or frozen-at with a serial, the actor and the time Records what an operator said about the freeze of a zone, so a start can trust it Forever. The prune of the ledger keeps its command

This file is the serial witness. For each zone apex it records the first and the last serial that this node served. A zone that goes back to a lower serial makes a secondary refuse its updates. The witness stops that.

A backup copies it into witness-copy/serials.sqlite. A restore merges that copy into the file of this node and never replaces the file. If you delete it, the history is lost. Every zone of the operator stops until tadoru zone witness accept or raise names it, with the server stopped. You state the largest EXPIRE that a secondary can hold with --max-expire. Until that deadline passes, IXFR (incremental zone transfer, RFC 1995) sends whole zones.

A damaged file moves aside to serials.sqlite.damaged, and the server makes a new one through serials.sqlite.new. A damaged file has the effect of a deleted one: the history is lost, and every zone stops until you name it with accept or raise.

Table What one row stores Why it exists How long a row stays
schema_version The number of one step that made the schema Tells a start which steps still must run Forever
witness One apex: the first and the last serial served, a digest of its records, the largest EXPIRE served, when it was served, and whether it is fenced Stops a zone from serving a serial that goes backwards Stays after its zone goes, up to 100,000 rows. A reset of an apex with no zone deletes the row. A reset of an apex with a zone rewrites it in place
store One row: when the file was made, a random id of it, and whether a loss of history was found Tells this file from one made again after a loss One row, forever
applied One audited command: its id, the id of the store, a fingerprint, and how it settled Lets a start settle a command that a crash cut between this file and control.sqlite A settled row stays 30 days. An open row stays until it settles. At most 100,000 rows
quarantine One apex after a new history: the time before which IXFR sends no differences, the EXPIRE it counts, and the old serials Stops IXFR from sending differences that a secondary could mix with the old history A row stays while a witness row stands at its apex. After a reset deletes the witness row, it stays until its deadline passes. At most 100,000 rows
uncovered One apex whose old serials no quarantine row covers Marks that the zone must serve past every old serial before IXFR sends differences Stays until an accept, raise or reset of the apex removes it

This file holds the time at which each record of a zone of the operator last changed on this node. The times belong to this node and are derived, so a backup does not carry them and a restore deletes the file with its side files.

The server opens the file at each start and writes it after each change of the records of a zone commits, before the new view is published. A change writes the rows of the records that it changed, and the point of the zone moves with it. A start checks the point of each zone against the zone. Where the files of the zone are unchanged, it moves the point forward. For any other mismatch it shows no times for that zone. Where the server cannot keep a time exact, it keeps none for that zone and logs it once (Troubleshooting has the line). DNS answers do not change.

If you delete the file, only the times go. Every record shows no time until it changes again, and the server makes a new empty file at the next start. A damaged file has the same effect.

A start moves a file that is no database, fails its checks or holds a newer schema to record_times.sqlite.damaged. It makes the new file as record_times.sqlite.new and renames it into place.

Table What one row stores Why it exists How long a row stays
schema_version The number of one step that made the schema Tells a start which steps still must run Forever
points One zone: its id, the version and revision of its records, two digests, and the journal and sequence that the rows match Tells a start whether the rows match the zone as it is now, or must be mended or dropped Until the zone is removed. The rows of times go with it
times One record: the zone id, a digest of the identity of the record, its lifetime, its off flag and the time of its last change, about 100 bytes with its key Shows when a record last changed Goes with its zone. A record with no row has no known time

This file holds the accounts: who can log in, what each can do, and what proves it. It is the only file with secrets, in the form of salted verifiers. The accounts are the same on every node of a cluster, and the file is the node’s own. The sessions stay on the node that issued them.

A backup copies it, in the clear without a passphrase and encrypted with one. A restore replaces the file and ends the sessions that the archive carried. If you delete it, nobody can log in, and a start writes a setup token for the first account. Accounts says how to make one.

A delete of an account, a verifier or a session zeroes the bytes it frees, and the server cuts the -wal after it. A damaged file stops the start with a message. The server does not move it aside.

Table What one row stores Why it exists How long a row stays
schema_version The number of one step that made the schema Tells a start which steps still must run Forever
accounts One account: an id that never changes, a unique name, a role, a display name, a password verifier, and the times it was made and changed The whole account in one place, so a rename or a delete cannot leave a credential behind Until an administrator deletes the account
tokens One token: the verifier of the token, its kind (setup or api), a label, the account it acts as, and the times it was made, expires and was used up Lets a script or a first start prove itself without a password. The token itself is never stored An API token stays until it is revoked or its account is deleted. A setup token expires and is used once
sessions One login in a browser: an id, the verifier of its cookie, the account, a forgery token, and the times it was made and expires Keeps a browser logged in, and holds the value that stops another site from acting in the name of the account Until it expires or ends. The server prunes expired rows. An account delete removes its sessions
account_changes One change to an account: the time, who made it, the action, the account, its name at that time, and a short detail with no secret The history of who changed which account, so a delete does not erase who did it Forever. Nothing deletes from it, and a deleted account leaves its rows

This file holds the query log and the hourly counts made from it. It is for reading what the server answered, and nothing else depends on it. The settings retention_days, retention_mib and stats_retention_days set how long its rows stay (Configuration).

A backup carries it only with --include-telemetry, and a restore replaces it only where the archive holds it. If you delete it, the log and the statistics go and nothing else. The server makes a new file at the next start. A query log that does not open leaves DNS running and records nothing.

Table What one row stores Why it exists How long a row stays
schema_version The number of one step that made the schema Tells a start which steps still must run Forever
queries One answered question: the time, the client, the name, the type, the code, the count of answers, how long it took, where the answer came from, the block result, and the path of a recursive answer The query log that GET /api/queries reads retention_days, 30 by default, and until the file is under retention_mib, oldest first
drops One gap: the first and last time, and the count of rows lost Lets an answer say that a range is incomplete, because the queue was full retention_days, and the size bound removes it only after all rows of queries are gone
redactions One redaction: the time, the column (name or client), how many rows changed, and who asked Records that somebody cleared data, because that changed state and not configuration Forever
stats_hourly One hour: the counts of questions, blocked, cached and failed, the median, 95th and 99th percentile of the time to answer, the counts by transport and by source, how many answers took each of 42 bands of time, and how its rows were kept: every question as a row, one question in N with its N, more than one N, or counts alone. An hour of transfers alone, which holds no N and no count, stores -2 and reads as every question a row. The mark is empty for an hour folded before version 22 of the file. Such an hour reads as every question a row where stats_sampled does not hold it, and as mixed where it does, because the file no longer says its N The statistics that a dashboard reads without scanning the log stats_retention_days, 1826 by default, counted from the hour
stats_clients The busiest clients of one hour, with one row other for the rest The list of top clients stats_retention_days, and sooner by the size bound: the lists of the oldest hours go first. A purge of client drops it
stats_domains The busiest names of one hour, with one row other for the rest The list of top names As stats_clients. A purge of name drops it
stats_blocked The 1000 names with the most blocked questions of one hour, and one row other The list of top blocked names As stats_domains
stats_qtypes The 32 most frequent record types of one hour, and one row for the rest The split of questions by type stats_retention_days
stats_rcodes The 16 most frequent response codes of one hour, and one row for the rest The split of answers by code stats_retention_days
stats_kept The device and transport counts of one hour as they stood when a redaction of client cleared its rows A rebuild of the hour after the redaction does not lower the counts stats_retention_days
stats_watermark One row: how far the folding of the log into hourly counts has reached A restart resumes the folding and does not rebuild it One row, forever
stats_lists_pages One row: the count of pages that the three top lists take Lets the size bound know the share of the lists without reading their pages One row, forever
queries_counted The count of one value of one facet of one hour, for the questions that a sampled log keeps no row of The statistics count every question when the log keeps one row in N As long as the rows of its hour
counted_watermark One row: how far the folding has read queries_counted A restart folds only the counts that came after it One row, forever
sample_runs The first row of each run of rows kept as one question in N, and its N The top lists weigh each kept row by the questions it stands for Until a newer run covers the oldest row that stays
stats_sampled One hour that a sampled log kept one question in N of: a question was not kept as a row, or a row stands for more than one question A top list of that hour is never called exact stats_retention_days