Upgrades
What is known about on-disk and wire compatibility between versions, the staged updates the watcher can do (version folders, read-only checks, staging, switching with automatic rollback, a one-node-at-a-time cluster roll; off by default), and a cautious procedure for replacing a binary.
Nothing updates itself unless you turn it on, there is no compatibility promise and no data migration tool. Raft DB is version 0.0.5; formats have changed during development and no release has been recorded. This page collects the facts that bear on an upgrade and gives a cautious routine. Treat every upgrade as a test.
What is fixed, and what is not#
| Item | State |
|---|---|
| Byte order and widths on disk and on the wire | Explicit little-endian, independent of the platform. Byte-exact tests (encoding_is_identical_on_every_platform, record_bytes_are_identical_on_every_platform) pin the document and log formats. |
| Log record format | [len][crc][payload], CRC-32C; the payload kinds are internal to the version. |
| Binary protocol | Version number in Hello: 1, and 2 for streams. A newer client talking to an older server falls back to version 1 behaviour where it can ("against an older server everything is as before"). |
| HTTP API | api major 0, minor 2 in GET /v1/server. Version 0 means it may change. The Studio's API contract is marked DRAFT. |
control.state | Has a version number (3 with table groups) so a newer server can read it. |
| Table definitions of the SQL front-end | Stored as documents in hidden tables; the code reads them back at each use. Whether an older definition reads under a newer build is not promised. |
| Compatibility between server versions in a cluster | Not documented or tested. |
The update popup#
The Studio tells you when a newer version exists. After it connects to a server, it asks https://www.raftdb.com/api/release (at most once a day, from your browser, with no cookies, no referrer and nothing about you or the data) which version is the newest. When that is newer than the version the server reports, a popup offers Download the update (opens the download page), Remind me in 3 days and Skip this version (it asks again for a later version), and has a box to turn the check off; the command Check for Raft DB updates in the palette (Ctrl+K) asks on demand. The setting is kept in the browser. The server itself never contacts the website; its page policy only allows the Studio's browser to make this one request. Running the new installer over an existing install is an upgrade: it keeps the data, the ports and the accounts. Versions before the one that added this popup have no such notice; they have to be updated by hand once.
Staged updates: what exists today#
The staged updates of decision D175 are built and tested up to the cluster roll (steps U1 to U5). They have not yet been used on a production installation.
Version folders. A program folder can hold several versions side by side:
versions/<version>holds each one, andcurrentsays which one runs (a link on Linux,current.txton Windows), withpreviousbeside it. Every version folder carries amanifest.jsonwith the size and SHA-256 of each file; on Windows the service wrapper checks it before a start and startspreviousinstead of a folder that does not match. The Linux install script installs this way, and its systemd units start the programs throughcurrent. On Windows the service wrapper readscurrent.txtbefore every start; a new installation there is in the version layout too (--flatkeeps the older flat folder), an existing flat installation stays flat on an upgrade, andraftdb-setup --migrate-layoutturns it into the version layout (it copies, deletes nothing, and the running programs go on until their next restart).raftdb-setup --stage-onlyandinstall.sh --stage-onlyput a version intoversions/without switching to it, stopping anything or changing a setting.Checks before a switch.
raftdb-server --check-config(settings) andraftdb-server --check-data DIR(data folder) only read: they open no port, create nothing and change nothing.--check-datareads every log of the folder and reports a damaged one by name (exit code 1).The watcher can download, check and stage a release, and is off by default. With
update_mode = off, the default, the watcher sends no request at all and creates no folder. Withupdate_mode = stageit reads the release feed, downloads a newer release (resuming a broken download), checks its size, its SHA-256 and the Ed25519 signature of the release's update manifest, unpacks it and puts it intoversions/<version>. On Windows it also checks the Authenticode signature of every program and library of the new version with Windows' own verification, in addition to the manifest (update_authenticode, defaultcheck: a broken or untrusted signature refuses the version, an unsigned file is a warning;requirerefuses unsigned files too). A damaged, cut-off, wrongly signed or older (replayed) release is refused and nothing changes. It never movescurrent, never touches the running version, the data or the settings, and claims no port. No release signing key is set in this version (none is built in, and the settingupdate_public_key_filethat names one is empty by default), so a watcher instagemode refuses every release from the site for now and says why. The settings are on Monitoring with the watcher.The watcher can switch to a staged version and puts the old one back if anything fails. This needs
update_mode = applyand three more settings written on purpose: a time window (update_window, for example02:00-04:00UTC, orany) and the commands that stop and start the server (update_stop_command,update_start_command). The watcher waits while a backup is running (it skips the round instead of interrupting it), stops the server, movespreviousandcurrent(each in one atomic step), starts it, and checks for up to two minutes (five on Windows) that it answers, reports the new version, takes a test write if it is the primary, and stays up. Any failure (the new program does not start, its port is taken, the test write fails) stops it, puts both pointers back as they were and starts the old version again; that version is not tried again by itself. If the watcher or the whole machine stops in the middle, the watcher's next start finishes the job by going back to the old version. The data folder is never written by a switch or a rollback; the watcher can hash it to prove that (update_data_hash = true).Rollback and clean-up.
raftdb-watch --config watch.conf update rollbackswaps back to the previous version the same careful way (refused when the newer version changed the data format: then a backup restore is the way back).update apply --to VERSION,update status,update cleanupandupdate recoverwork in every mode. The previous version is kept for one week (update_keep_previous_days), then removed; the running version is never removed.A whole cluster with one plan. In a cluster with a quorum of watchers you give an update plan once, to the master watcher (
PUT /v1/update/planon its status port, with the cluster secret):target,mode = stageorapply,window, optionallyskip. Every watcher gets it through the quorum's log and keeps it over a restart. The master then switches one node at a time: nodes that lead nothing first, a node that leads a group only after the group was handed to a caught-up node, its own node last; before each node every node must answer and be caught up. A node that the shared node health table holdsdownor inmaintenanceholds the roll and is never given a group. The first node that fails is put back on its old version by its own watcher and the roll stops there until you look. A node whose watcher saysupdate_mode = off(orstage) is skipped and left as it is. If the master watcher goes away, another one continues without repeating a step. A node that cannot reach www.raftdb.com can fetch the files from a peer watcher (update_peers,update_peer_listen) and checks the signature and SHA-256 itself.Client connections: the node being switched is stopped and started, so a client connected to it loses its connection once and reconnects; writes it had acknowledged are kept. In a cluster the switched node never leads a group, so writes go on through the others.
What does not happen yet: no release signing key is set in this version, so nothing is downloaded or switched automatically from the website; the watchers themselves are not updated by the roll (update them by hand or with the installer, all before the first plan); the server has no pause of in-flight requests before a stop.
The settings and the plan format are on Monitoring with the watcher. Automatic update is off by default: with update_mode = off the watcher never contacts www.raftdb.com, downloads nothing and changes nothing, and a cluster plan never touches that node. A manual update (the installer, or update apply) still works.
A cautious routine#
- Read the changelog. Look at the changelog and the newest decisions in the decision log for anything that touches formats or settings (for example the removal of the
clusterprofile in D51 C4: a server started with it now fails with a message that points to the watcher). - Take a cold copy of the data directory (Backup and recovery).
- Check the settings with the new binary before stopping the old one:
new-raftdb-server --config raftdb.conf --check-configwrites nothing. A setting that was removed or renamed is an error there. - Stop the old server and confirm that it has exited (no second server on one directory).
- Replace the binaries (
raftdb-server,raftdb-mysql,raftdb-watch). On Linux withinstall-service, running it again copies the binary to/usr/local/bin/raftdb-server; it never changes an existing/etc/raftdb/raftdb.conf. - Start and check: the start line,
GET /v1/serverand a few reads and writes; for the SQL front-endSELECT VERSION()and your own smoke test. - Keep the copy until you have run on the new version long enough to trust it. A rollback is: stop, restore the copy, start the old binary.
Clusters#
A rolling upgrade of a three-node cluster from 0.0.4 to 0.0.5 was done by hand (stop a follower, replace its programs, start it, wait until it has caught up, then the next, the primary last by handover), checking every table against a snapshot taken before; it worked, and a node of one version followed a primary of the other during it. That is one run, not a promise for every pair of versions: read the changelog for a change of format first. And the watcher quorum needs a majority (two of three) to keep a primary, so stopping two nodes at once leaves no writable node. A checkpoint on the primary makes followers fetch the table again.
Upgrade the watchers and servers in the same maintenance window if you can; stop the watchers first so they do not restart the server you are replacing (or accept the restart-budget reports).