Skip to content

Zone failure

A lowtide cluster runs gateway pods in two zones. Each pod’s WAL is on a regional persistent disk, which keeps a replica in both zones. When a zone fails, you move its pods to the other zone, where they mount the same disks and recover.

  • Publishes keep working in the surviving zone. Clients there already use local pods. Clients whose zone has no ready pod fall back to the other zone.
  • Acknowledged messages are not lost. A publish is acknowledged only after the WAL is synced, and the regional disk has written it to both zones.
  • Messages written by the failed pods are delayed. What they had already uploaded is readable by every pod. The rest, about one segment window plus any upload backlog, is only on their WAL disks. It stays invisible until a pod mounts those disks again. Other streams of the same topic keep flowing.
  • Subscriptions move. Shards served by the failed pods move to surviving pods once their lease expires (15 seconds by default). Delivery restarts from the last recorded acknowledgement position, so recent messages are delivered again.
  • The failed pods don’t move by themselves. StatefulSet pods on unreachable nodes stay Terminating or Unknown until they are deleted, and each StatefulSet is pinned to its zone.

Target: done within 5 minutes. You need node capacity in the surviving zone for the failed zone’s pods. The module’s gateway node pool autoscales to twice the pod count per zone for this.

Check that the nodes of the whole zone are NotReady and look at the Google Cloud status page. If only one node is down, skip step 3 and handle it the same way otherwise: fence it and delete the pod. It then starts again in its own zone.

lowtide has no fencing of its own. If an old pod is still running somewhere and a new pod mounts the same disk, both write the same stream. They assign the same offsets and upload over each other’s segments, which corrupts the stream. Only go on when the nodes are really down.

Mark them out of service. Kubernetes then force-deletes their pods and detaches their volumes without waiting for the kubelet:

Terminal window
for n in $(kubectl get nodes -l topology.kubernetes.io/zone=us-central1-a -o name); do
kubectl taint "$n" node.kubernetes.io/out-of-service=nodeshutdown:NoExecute --overwrite
done

Pods keep their names, disks and stream names. Only where they run changes.

Terminal window
helm upgrade lowtide CHART -n lowtide --reuse-values \
--set zoneFailover.us-central1-a=us-central1-b

If Terraform manages the release, also add the same value to the module’s helm_values, so the next terraform apply keeps it:

helm_values = [yamlencode({ zoneFailover = { "us-central1-a" = "us-central1-b" } })]

Only after step 2, if any are still Terminating:

Terminal window
kubectl -n lowtide delete pod lowtide-us-central1-a-0 --force --grace-period=0
Terminal window
kubectl -n lowtide get pods -l lowtide.dev/zone=us-central1-a -o wide -w
kubectl -n lowtide describe pod lowtide-us-central1-a-0 | sed -n '/Events/,$p'

Multi-Attach error or FailedAttachVolume means the old attachment has not been released yet. Detaching a disk from a machine in a failed zone can itself fail at the Compute Engine API. Compute Engine can force-attach a regional disk in this case. If the disk doesn’t attach within a few minutes, follow Google’s guidance on regional persistent disk failover or contact Google Cloud support.

When the pod starts in the new zone it:

  1. connects to the database and registers its stream under the same name, now with the new zone;
  2. replays every WAL file in order, cutting off a torn last record, and loads the messages into memory, where its own subscribers and same-zone peers can read them at once;
  3. starts serving without waiting for uploads, then uploads the recovered files in order. A file that was already uploaded is simply written again.

Its messages now belong to the new zone. Subscribers start receiving them about 45 seconds after the pod registers there, once every pod has seen the move (Cross-zone delivery).

Terminal window
kubectl -n lowtide logs lowtide-us-central1-a-0 | grep -E 'recovered WAL file|writer stream registered|gateway serving'

lowtide_pending_upload_bytes on the pod falls back to normal as the uploads finish.

Recovered data stays in memory until it is uploaded, so a large WAL backlog needs a matching memory limit (WAL disk full).

When the zone is healthy and its nodes are Ready:

  1. Remove the taints:

    Terminal window
    kubectl taint nodes -l topology.kubernetes.io/zone=us-central1-a node.kubernetes.io/out-of-service-
  2. Check the disks’ status in Compute Engine. The replica in the returning zone has to catch up, and the disks can be slower meanwhile. Fail back when traffic is low.

  3. Remove the failover:

    Terminal window
    helm upgrade lowtide CHART -n lowtide --reuse-values --set zoneFailover.us-central1-a=null

    Remove it from helm_values too if you added it there. The StatefulSet rolls its pods back one at a time, each with a graceful shutdown (Upgrades and scaling).

CHART is the chart you installed from: with the Terraform module, the chart that comes with the module version you applied.