diff --git a/docs/2-handbook/swarm/matrix.md b/docs/2-handbook/swarm/matrix.md index a3984ef19..fb003d183 100644 --- a/docs/2-handbook/swarm/matrix.md +++ b/docs/2-handbook/swarm/matrix.md @@ -44,8 +44,12 @@ Same shape as [`gateway.md::hive-forge container shape`](../../4-implementation/ job would hold the container's start for as long as tuwunel's start takes.) tuwunel's own start, which replays the database's write-ahead log from the beginning at every open, has its own limit of 30 - minutes, and extends it while it reports progress. While it starts, the - gateway answers for the homeserver with an error, and the swarm's matrix + minutes, but that limit doesn't bound the open: tuwunel asks systemd for 30 + seconds more every 15 seconds while it opens the database, whether or not it + has advanced, so only a stop ends a wedged open. RocksDB's own log goes to the + journal at `info` (`rocksdb_log_level`, `rocksdb_log_stderr`), so a replay + (`Recovering log #…`) and the flushes after it show there. While it starts, + the gateway answers for the homeserver with an error, and the swarm's matrix clients retry. ## Identity vs API listener: `serverName` vs `gatewayHost` diff --git a/nix/host-modules/hive-matrix.nix b/nix/host-modules/hive-matrix.nix index e3e554303..b014fbaa8 100644 --- a/nix/host-modules/hive-matrix.nix +++ b/nix/host-modules/hive-matrix.nix @@ -1055,6 +1055,15 @@ in # display names are clean (just the agent name, no emoji). new_user_displayname_suffix = ""; + # Without these the database open is silent: tuwunel hands + # RocksDB's log to its own logger at `rocksdb_log_level = + # "error"`, so `Recovering log #…` and the flush and compaction + # lines never reach the journal, and nothing tells a replay + # from a wedged open. `rocksdb_log_stderr` writes the lines to + # stderr, past tracing's filter, which is the journal. + rocksdb_log_level = "info"; + rocksdb_log_stderr = true; + # tuwunel's OIDC server and this list are the two ends of one # pipe: `oidc_native_auth` stays false (its default), which # upstream defines as "the OIDC server runs only to broker @@ -1107,11 +1116,15 @@ in # Upstream's `ProtectSystem = "strict"` leaves `/run` read-only. systemd.services.tuwunel.serviceConfig.ReadWritePaths = [ socketDir ]; - # tuwunel asks systemd for 30 s more every 15 s while it opens the - # database (`EXTEND_TIMEOUT_USEC`), which moves the deadline past - # this value for as long as it reports; this is the limit when it does - # not. 30 min is ten times the 3 min of CPU a replay has already used - # without ending. + # ⚠️ This does not bound the database open. While it has a notify + # socket, tuwunel asks systemd for 30 s more every 15 s + # (`EXTEND_TIMEOUT_USEC`, in its `router/run.rs` reporter), whether + # or not the open has advanced, so each report moves the deadline to + # 30 s past itself. The value is the limit only up to the first + # report. A wedged open never ends by itself: only a stop, or the + # operator, ends it. What bounds it is a separate question. 30 min + # is ten times the 3 min of CPU a replay has already used without + # ending. systemd.services.tuwunel.serviceConfig.TimeoutStartSec = "30min"; # The probe's file lives in upstream's `RuntimeDirectory`. diff --git a/nix/module-eval/swarm-services-switch.nix b/nix/module-eval/swarm-services-switch.nix index fac2cbca3..31a171d58 100644 --- a/nix/module-eval/swarm-services-switch.nix +++ b/nix/module-eval/swarm-services-switch.nix @@ -1019,6 +1019,19 @@ let && lib.elem "swarm-matrix-appservice-sync.service" booted && lib.elem "swarm-matrix-appservice-render.service" booted; } + { + # The database open is what takes hours on a large log, and tuwunel + # hands RocksDB's log to its own logger at `error`, so neither a replay + # nor a wedge shows in the journal. The two keys make RocksDB's recovery + # and flush lines reach it through stderr. + name = "the homeserver logs RocksDB's own messages to the journal"; + ok = + let + global = + serviceContainersWithCi.containers.hive-matrix.config.services.matrix-tuwunel.settings.global; + in + global.rocksdb_log_level == "info" && global.rocksdb_log_stderr == true; + } { # On the bridge by DHCP, with all three listeners on sockets: nothing # the bridge can dial. Every vhost location that forwards goes through