This commit is contained in:
1 parent
b724a21a0d
commit
d73fa2c435
45 files changed
+2733
-226
No files matched your search
@@ -0,0 +1,74 @@
|
||||
# Metadata failover drill
|
||||
|
||||
This isolated test runs three PostgreSQL members under Patroni, three etcd voters,
|
||||
two storage nodes, and one ObjectStore gateway. It tests automatic metadata
|
||||
promotion and gateway reconnection. All containers run on one machine, so it
|
||||
does not establish physical fault isolation or production readiness.
|
||||
|
||||
Requires Docker Compose, Python 3, and about 2 GiB of available Docker memory.
|
||||
PostgreSQL and etcd use disposable volumes that survive container restarts. Only the gateway
|
||||
has a published port, allocated on loopback. The script generates a unique
|
||||
Compose project and removes its containers and volumes on exit. It never uses
|
||||
the repository's `.env` or an existing deployment.
|
||||
|
||||
```sh
|
||||
python3 scripts/test-ha.py --output out/ha-report.json
|
||||
```
|
||||
|
||||
To reuse an image built from this checkout, add `--image IMAGE`. The report path
|
||||
must not already exist. Keep reports outside Git if they contain local details.
|
||||
|
||||
The test:
|
||||
|
||||
1. Waits for a primary and synchronous standby, then writes small signed objects.
|
||||
2. Kills the primary container without stopping the gateway.
|
||||
3. Waits for Patroni promotion, reads every acknowledged object, and writes more.
|
||||
4. Restarts the old primary and checks that it rejoins the cluster.
|
||||
5. Kills both standbys and checks that strict replication stops acknowledging writes.
|
||||
6. Restores them, then stops two etcd voters and checks that readiness and writes fail.
|
||||
7. Restores quorum and verifies acknowledged objects again.
|
||||
|
||||
The database uses synchronous replication with `synchronous_mode_strict: true`.
|
||||
Losing the eligible synchronous replicas can stop writes; availability must not
|
||||
silently take priority over the configured durability policy. Requests interrupted
|
||||
by a failure have uncertain outcomes and are not counted as acknowledged.
|
||||
See [Patroni replication modes](https://patroni.readthedocs.io/en/latest/replication_modes.html).
|
||||
|
||||
## Operating metadata HA on separate machines
|
||||
|
||||
Use the tested configuration as a behavior reference, not deployment credentials.
|
||||
The fixture has public test passwords, private-network plaintext traffic, and no
|
||||
hardware watchdog. Never expose its database, etcd, or Patroni APIs.
|
||||
|
||||
For a separately operated HA deployment:
|
||||
|
||||
1. Place the three PostgreSQL members and etcd majority across independent machines.
|
||||
Give each member durable storage and unique credentials. Keep ObjectStore's
|
||||
database role separate from PostgreSQL superuser and replication roles.
|
||||
2. Configure TLS and authentication for etcd peer/client traffic and Patroni's
|
||||
management API. Enable PostgreSQL TLS with hostname verification on every client.
|
||||
3. Enable Patroni synchronous mode, strict mode, and at least one synchronous
|
||||
standby. Keep PostgreSQL `synchronous_commit=on`; do not override it in the
|
||||
ObjectStore database or role settings.
|
||||
4. Configure and test host fencing. Patroni's required watchdog mode refuses
|
||||
promotion if its watchdog is unavailable. A stalled controller must not leave
|
||||
an old primary accepting writes after its lease expires. The local fixture
|
||||
intentionally cannot reboot the machine. See
|
||||
[Patroni watchdog requirements](https://patroni.readthedocs.io/en/latest/watchdog.html).
|
||||
5. Give each gateway and maintenance process a primary-only JDBC URL:
|
||||
|
||||
```text
|
||||
jdbc:postgresql://db-a:5432,db-b:5432,db-c:5432/objectstore?targetServerType=primary&connectTimeout=3&socketTimeout=10&hostRecheckSeconds=1&sslmode=verify-full&sslrootcert=/certs/metadata-ca.pem
|
||||
```
|
||||
|
||||
6. Back up PostgreSQL and storage independently of this cluster. Rehearse restore
|
||||
into fresh infrastructure; replication does not protect against deletion or
|
||||
an administrative mistake. Recover the managed-credential encryption key with
|
||||
the metadata backup when managed credentials are enabled.
|
||||
7. Repeat the drill on those machines, including network partitions and fencing,
|
||||
before directing important data to them. Monitor replication lag, quorum,
|
||||
disk space, backup age, and restore results.
|
||||
|
||||
ObjectStore reconnects to the elected primary; Patroni controls promotion and
|
||||
demotion. Do not promote a database by hand while its former primary can still
|
||||
accept traffic. Do not force promotion of a stale replica to make a test pass.
|
||||
Reference in new issue
Block a user