Repository navigation
docs(upgrade): confirm the server is stopped before the upgrade steps - #753
LeeroyHannigan wants to merge 3 commits into
Conversation
The General Upgrade Procedure, the version-history blocks and the rollback steps began with `extenddb stop` and carried on with whatever it returned. `extenddb stop` finds the server through its PID file, so it stops nothing and exits 1 for a `serve --foreground` server, a container, a wrong `--config`, or a different user, and the steps that follow then back up, migrate or copy files under a live old server. Each block now runs in a subshell and, before it touches a file or a database, confirms `extenddb status` reports the server is not running, stopping without closing the operator's shell when it still answers and behaving the same under `set -o pipefail`. Step 1 explains that `extenddb status` only checks 127.0.0.1 on the configured port, so a server on another address or host is confirmed through its runner. Text only; no version literal changed.
docs/manuals/07-upgrade-manual.md conflicted in the SQLite rollback step. Main added the paragraph on what the 0.1.x binaries print for the backup_items rebuild. The merged step keeps that paragraph and this branch's rollback sentence, which confirms that the server is down first.
docs/manuals/07-upgrade-manual.md keeps two rollback changes from main: step 2 restores both databases into new ones, and the PostgreSQL block sets umask 077. It keeps this branch's check that the server is down in both places.
navareamol
left a comment
There was a problem hiding this comment.
The guard passes while the server is still up when the server listens on a port other than the one in extenddb.toml. I started a server with extenddb serve --config extenddb.toml --port 18754 while the config said 18753, then ran the step 1 block: extenddb stop printed No extenddb server is running on port 18753 and the guard let the block go on. A foreground server whose port came from EXTENDDB__SERVER__PORT in its own environment did the same. On SQLite the next line copies the open database file. The new text names only another bind_addr and another host as the cases extenddb status cannot see. I think the limit sentence should also name a port set by --port, by an environment variable the server has and your shell does not, or by a container's published port, and say that extenddb stop and extenddb status take --port.
grep -q can make extenddb status panic. It prints two lines, grep -q exits after the first, and the second write fails with thread 'main' panicked at ... failed printing to stdout: Broken pipe (os error 32). The || true hides the exit code, so the guard still passes, but the reader sees a panic in the middle of an upgrade. I saw it twice on a busy host while running the SQLite and 0.0.3 blocks, and every time in 100 runs with status pinned to grep's CPU at low priority. With grep 'is not running' >/dev/null, which reads all input, it did not happen in 100 runs under the same pinning. Could the five blocks use that form?
Two sentences about extenddb stop do not match crates/app/src/cmd_stop.rs:
- "exits 1 ... when it runs as a different user".
is_process_aliveiskill(pid, 0) == 0, which is false for a process of another user. With a readable PID file that names such a process,extenddb stopprintsProcess <pid> is not running. Cleaning up stale PID file., exits 0 and removes the file. Exit 1 happens when the other user cannot find the PID file, as with the defaultrun_dirunder$HOME. Maybe "it may report the server as not running" covers both. - "a server started with
serve --foreground(which writes no PID file)".serve --foreground --write-pid-filewrites one, andextenddb stopthen stops that server. I think "unless it was started with--write-pid-file" belongs there.
Step 1 now says "Start it again the same way when the procedure is done", but each wrapped block still ends with extenddb serve --config extenddb.toml, as does the last step of the General Upgrade Procedure. For the Deployment Guide's systemd unit that line starts a second daemon outside systemd, as the user running the upgrade. Should those lines say to start the server through whatever runs it?
The description says #737 "uses the same guard and subshell form". #737 now uses the guard without a subshell and without || true, asks for an absolute config path, and adds a pg_stat_activity count for servers on other hosts. Could the description be updated, and would that count also help the PostgreSQL block here?
I will approve once the port case is named in the step 1 text and the guard reads all of status's output.
What
The upgrade manual's General Upgrade Procedure, its version-history blocks (catalog 0.0.4 for PostgreSQL, SQLite and Cassandra, and catalog 0.0.3) and its rollback steps began with
extenddb stop --config extenddb.tomland carried on with whatever it returned. Each now confirms the server is down before any backup, migrate or file step.extenddb stopfinds the server through the PID file the daemon writes, so it stops nothing and exits 1 for aserve --foregroundserver (no PID file), a container, a--configpath that does not name the server's file, or a different user; it says to stop through whatever runs the server (sudo systemctl stop extenddb, the container runtime, orextenddb stop) and to start it again the same way; and it notes thatextenddb statusonly checks 127.0.0.1 on the configured port, so a server on another address or host must be confirmed through its runner.extenddb stop, runs{ extenddb status --config extenddb.toml || true; } | grep -q 'is not running'and stops the block if the server still answers. The subshell means a copied recipe halts the upgrade without closing the operator's shell, and the|| truemeans it behaves the same underset -o pipefail.Why
extenddb stopsignals the process named in the PID file. A server started withserve --foreground, or a container, writes no PID file, soextenddb stopexits 1 and the server keeps running;extenddb stopalso stops nothing when run with another--configor as another user. Its exit status does not show whether the server is down. The steps that follow then act against a live old server: the SQLite blocks copy or replace the database file while it is open (a cause of corruption in the SQLite documentation), and the PostgreSQL and Cassandra blocks runmigrateandserve. Confirmingextenddb statusreports the server is not running before those steps stops that.The Admin Guide's backup and restore section, open PR #737, uses the same guard and subshell form for the same reason. On
maintoday the PostgreSQLmigrateadvisory lock only orders migrations, so amigraterun under a live old server is possible; open PR #741 adds a lock that makesmigratewait for a running server, which would narrow the exposure to the dump and copy steps.Testing done
Text change only, to
docs/manuals/07-upgrade-manual.md. The guard was exercised with the exact strings and exit codes ofextenddb status(crates/app/src/cmd_status.rs prints... is not running ...and exits 1 when nothing listens on 127.0.0.1 at the configured port): under bash, under bash withset -o pipefail, and under zsh, it continues when the server is down and ends the block, without closing the outer shell, when the server is up. The edited blocks were not run as a full upgrade rehearsal across the four backends.bash -nandzsh -nparse step 1, the SQLite and the 0.0.3 blocks; the PostgreSQL and Cassandra blocks carry the manual's existing<host>/<admin>placeholders, which are not valid shell until replaced, onmainas here. The upgrade manual is in the exempt list ofcrates/storage-postgres/tests/doc_version_literals.rs, so that test does not read the file; no CI job runs the manual's code blocks.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
No breaking changes. No Rust file changes, so the formatting and clippy boxes are left unchecked. CI runs the workspace tests on this PR and they pass.
ADR / RFC: n/a
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.