Skip to content

v0.27.0

Choose a tag to compare

@github-actions github-actions released this 13 Oct 05:32
· 109 commits to main since this release
dda3d11

Added

  • Active-passive high availability (#65, phase 1). With MONGORESCUE_HA_MODE=active-passive (default off) and MONGORESCUE_HA_TARGET, _CLUSTER, _LEASE_TTL (30s), _RENEW_INTERVAL (10s) and _SNAPSHOT_INTERVAL (5m), or the matching flags, two or more instances with their own data directories and the same secret key share a lease on a storage target: the holder is active, the others are read-only standbys. Design and failure matrix in docs/design/ha.md, operations in docs/production.md. See also docs/kubernetes.md.
    • Lease. The optional storage capability storage.LeaseStore writes with compare-and-swap: S3 PutObject with If-None-Match/If-Match (AWS S3, MinIO), local disk with O_EXCL and a flock on a sidecar file; HA refuses to start on a storage that ignores the conditions (startup probe) or on a target with Object Lock. The lease _mongorescue/ha/<cluster>/lease.json carries an epoch that grows with every takeover; expiry is measured on each instance's own monotonic clock from the last observed change, never from another clock. The active instance steps down ttl − renew after its last successful renewal.
    • Roles. A standby serves no data and accepts no sign-in (its users, sessions and API keys are not trusted): only /api/v1/health (now with role and ha), /metrics without credentials limited to process, build and HA series, and a static standby page naming the active instance in all eight languages; the API, signing in, single sign-on and MCP answer 503 with Retry-After. It runs no scheduler, PITR collector, copies, integrity sweeps, re-encryption, metadata backups, RPO checks, heartbeat, notification outbox or audit forwarding. A graceful shutdown of the active instance writes a last snapshot and releases the lease.
    • Fencing. Runs start only while the lease is held, backups and restores are not recorded as completed without it (the archive is kept), and backup, restore and job run records carry ha_epoch.
    • Metadata handover. The active instance writes an encrypted snapshot of its database to _mongorescue/metadata/ha/<cluster>/ after every finished run and at least every snapshot interval (the newest 12 are kept). A new active instance snapshots at once. On takeover a standby restores the snapshot with the highest epoch (its own database kept as mongorescue.db.bak-<UTC time>-epoch<N>, the newest three copies), takes over without one only when no lease existed either, keeping its own database (else it stays standby and MongoRescueHATakeoverFailed fires), always with an epoch above every snapshot's, marks interrupted runs, imports the archives written after the snapshot, and runs once each job whose cron fire fell in the gap, but only when it can verify that the fire did not run; otherwise it sends ha.catch_up_skipped.
    • Observability. Events ha.took_over and ha.stepped_down (sent to every enabled channel), the series mongorescue_ha_role, _epoch, _lease_healthy, _lease_errors_total, _takeovers_total, _takeover_duration_seconds, _takeover_failures_total and _step_downs_total, and the alert rules MongoRescueHANoActiveInstance and MongoRescueHATakeoverFailed.
    • In HA mode secret.key rotation is refused (409) with a pointer to the cluster procedure in docs/production.md, so one instance never silently breaks the others' takeover.
    • The Helm chart has an ha section (one release per instance; replicas stays 1), and docs/production.md has an HA checklist and guidance on running MongoRescue in another failure domain than the databases it protects.
  • In-place point-in-time restores (#142): an administrator can have a point-in-time restore end with the original databases holding the restored state. See docs/pitr.md.
    • Request. "pitr": {"in_place": true, "confirm_in_place": "<db1>,<db2>"} with databases listing exactly the confirmed databases (never the whole instance), optionally "keep_clone": true; admin only, on the stream's own connection. With the two-person rule on it waits for approval (action pitr_in_place). MCP never offers it: pitr_restore stays clone-only. Refused with 409 while active-passive HA is on.
    • Steps, one run. The restore into clones runs unchanged (checksums, op-count cross-check, the connection's post-restore commands on the clones); then a mandatory safety backup of each original (label pre-pitr-in-place, restore_id), the stream is paused (its chain ends as stopped), each clone is piped over its original (mongodump --archive | mongorestore --drop, then the collections the clone lacks are dropped, only once the copy holds every collection and document count recorded for the clone after the restore; a clone that lists nothing ends the run with the originals untouched, so an original is never emptied), the clones are dropped unless keep_clone, and the stream is enabled again with a new chain and a new base backup. New run phases safety_backup and swapping, record field pitr.in_place, preflight check in_place (refuses while a backup or restore of the databases runs).
    • Failures. A failure before the swap drops the clones and leaves the originals untouched; a failure during the swap keeps the clones and the safety backups and names both with recovery steps; the stream is enabled again either way, also after a restart interrupted the run.
    • Events. restore.in_place_pitr (succeeded or failed, with safety_backup_ids), selectable by notification rules, and security.destructive_action (pitr_in_place) when it starts.
    • Dashboard. The point-in-time restore wizard offers administrators Replace the original databases behind a danger confirmation in which the database names are typed, with the downtime, safety backup and approval notes, in all eight languages; the default stays a restore into new clones.
    • A PITR collector whose stored position belongs to an ended chain no longer fails on every commit: after a pause (stopped) it starts a new chain at the newest entry; after a gap, a replica set change or a divergence that a stop interrupted before the next chain started, it finishes the break (a new chain at the oldest entry or the divergence point, and a base backup).

Changed

  • GET /api/v1/jobs is paged by cursor (API change, #156). It returns one page of jobs in the order of sort (name, the default, next_run, last_status or created_at) and order (asc or desc), ties broken by ID: limit (1-500, default 100) and after (the previous page's meta.next, which carries the order and is refused by another one), with meta: {total, limit, next}. Without limit the answer is now the first 100 jobs instead of every job; next is present while more follow. The filters (q, enabled, connection_id, database, schedule, last_status) combine with the cursor, and a job created or deleted between two pages never shifts another one. The CLI (mongorescue list jobs), the API client, the MCP list_jobs tool (its next_cursor is now this cursor) and the dashboard page through. See docs/api.md.
  • The dashboard's Jobs table pages, filters and sorts on the server, like Backups: rows per page (25, 50 or 100), the range of the total and Previous / Next; the Name, Last run and Next run columns sort every page (the Connection, Database, Schedule and Status columns no longer sort).
  • GET /api/v1/stats/history is fast at 10,000 jobs (#156): the next day's runs are computed per job only as far as needed (the 500 earliest are kept without collecting every activation of 96 days ahead), the runs and last successes of jobs with several databases are read in one bounded query per 500 jobs instead of two queries per job, and the answer is shared for 10 seconds among callers with the same window, zone and connection access (computed once when they ask at the same time) and dropped earlier by backup, run, verification, retention, bulk, deletion and job changes (also job changes applied by the scheduler, such as pending changes and approvals). Migration 0028 adds indexes for the jobs list's orders (name, creation time, next run) with and without its connection and state filters and covering indexes for the history's per-day and stored-size figures and the newest backup per job and database. The readiness report and RPO check compute each distinct schedule's interval once instead of once per job, and the RPO checks that job writes and finished backups ask for are coalesced to one every 5 seconds instead of one per write (creating 10,000 jobs through the API runs about twice as fast). The load test enforces a p95 under 300 ms for the jobs list and the history with 16 clients.
  • GET /api/v1/stats, GET /api/v1/readiness, the jobs list's filters (q, database, schedule, last_status) and its last_status order are fast at 10,000 jobs (#169). Migration 0029 keeps on every job a lower-cased search text, its schedule frequency, the databases it names or knows (filled by every job write, and for existing jobs when the database opens) and its last status with the start time of that backup or run (kept by triggers on backups and runs, and filled by the migration), with indexes for the last-status order and the filters, so the list filters, counts and pages in SQL instead of reading every job. Within an outcome the last_status order now puts the newest backup or run first (it used the job's last scheduled run). The statistics and the readiness report are computed once for every caller with the same connection access and shared until a job, backup, run, restore, restore test or RPO breach is written (a change counter the migration's triggers keep, so writes by the scheduler and deletions count too), an event arrives or a job changes, or 10 seconds (statistics) or 5 seconds (readiness) pass. The load test enforces a p95 under 300 ms for these calls with 16 clients.

Fixed

  • Cancelling a run at the moment it starts no longer races with the opening of its log (found by the race detector on Windows CI).
  • The PITR collector could end a healthy chain as diverged (pitr.diverged) right after a former primary rejoined its replica set. Its oplog reads "on the primary" (confirming a gap or divergence, and reading chunks when no secondary is current) went to any secondary under the session's secondaryPreferred read preference. When that secondary was the former primary, which had not yet rolled back, the newest stored entry seemed to be missing. These reads now go to the primary (found by the nightly replica set scenarios).
  • The connection defaults (authSource, serverSelectionTimeoutMS, connectTimeoutMS) handed to the Database Tools were merged into the last option's value when that value ended in ? (e.g. appName=a?), so they did not apply (found by the nightly fuzzing).
  • The PITR oplog filter refuses a transaction entry that is not on admin.$cmd as malformed instead of copying it with its namespace unchecked (found by the nightly fuzzing).
  • A security.key_rotated alert could be lost when the process died right after a rotation finished: it went through the in-memory event queue. Key rotation alerts are now stored in the notification outbox before the rotation is marked finished and the request answered, and a crash before that leaves the rotation marker, so the next start sends the alert (at least once).
  • The PITR collector of a connection with directConnection=true failed while its member was a secondary (during a stepdown, or for good when connected to a secondary): it dialled the address the member advertises, which is unreachable behind a port mapping or proxy. It now reads from the connected address.
  • A notification could be delivered twice in normal operation. The outbox dispatcher acted on a list of pending deliveries that it read while one of them was being sent: if that delivery finished and was removed before the dispatcher reached it, the stale entry was sent again. A delivery is now claimed only when nothing of its channel settled since the read, so it is sent once; only a crash can repeat it (#157's at-least-once).
  • PITR retention could delete the oplog chunks and the base backup that a running point-in-time restore or chain test was still reading, so it failed with object not found (found by the nightly soak test, where a new base pushed the chain test's base out of the kept count mid-test). A point-in-time restore, chain test or in-place restore now pins the base and the chunks it planned (on the primary and in a copy chain alike) until it ends; retention, the chunk and copy purges and the purge of deleted backups skip pinned objects and delete them on a later run, logging how many they skipped. The plan is pinned first and checked second: if retention deleted part of it in between, the restore is planned again, and after three attempts it is refused (ErrPITRNotRestorable) instead of starting a restore bound to fail. The base's archive is pinned as well, so the purge also keeps the old archive of a base re-encrypted meanwhile (its tombstone has another ID). Pins live in memory; a running restore refreshes its pin, and one not refreshed for an hour (abandoned without a release) stops counting with a warning, so it cannot hold retention back for good.