Skip to content

docs(upgrade): confirm the server is stopped before the upgrade steps - #753

Open
LeeroyHannigan wants to merge 3 commits into
mainfrom
fix/upgrade-manual-stop-check
Open

LeeroyHannigan wants to merge 3 commits into
mainfrom
fix/upgrade-manual-stop-check

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

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.toml and carried on with whatever it returned. Each now confirms the server is down before any backup, migrate or file step.

  • The General Upgrade Procedure's step 1 is now "Stop the server, and confirm it is down". It explains that extenddb stop finds the server through the PID file the daemon writes, so it stops nothing and exits 1 for a serve --foreground server (no PID file), a container, a --config path 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, or extenddb stop) and to start it again the same way; and it notes that extenddb status only checks 127.0.0.1 on the configured port, so a server on another address or host must be confirmed through its runner.
  • Each version-history block now runs in a subshell and, after 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 || true means it behaves the same under set -o pipefail.
  • The Rollback Procedure's "Stop the server" step and the SQLite rollback sentence now point at step 1's confirmed stop, because they also stop the server and then drop, restore or replace data.

Why

extenddb stop signals the process named in the PID file. A server started with serve --foreground, or a container, writes no PID file, so extenddb stop exits 1 and the server keeps running; extenddb stop also stops nothing when run with another --config or 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 run migrate and serve. Confirming extenddb status reports 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 main today the PostgreSQL migrate advisory lock only orders migrations, so a migrate run under a live old server is possible; open PR #741 adds a lock that makes migrate wait 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 of extenddb 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 with set -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 -n and zsh -n parse 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, on main as here. The upgrade manual is in the exempt list of crates/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

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, 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.

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.
@LeeroyHannigan LeeroyHannigan added the documentation Improvements or additions to documentation label Nov 2, 2026
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 navareamol self-assigned this Dec 2, 2026

@navareamol navareamol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. "exits 1 ... when it runs as a different user". is_process_alive is kill(pid, 0) == 0, which is false for a process of another user. With a readable PID file that names such a process, extenddb stop prints Process <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 default run_dir under $HOME. Maybe "it may report the server as not running" covers both.
  2. "a server started with serve --foreground (which writes no PID file)". serve --foreground --write-pid-file writes one, and extenddb stop then 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants