Mirroring to Pub/Sub
While a topic moves, lowtide copies every message published to it to the Pub/Sub topic with the same full name. Subscriptions still on Pub/Sub keep receiving everything, so you can move publishers first and subscriptions later, one at a time.
Mirroring goes one way only: from lowtide to Pub/Sub. It is a migration aid. Turn it off once no subscription is left on Pub/Sub.
Turn it on and off
Section titled “Turn it on and off”The switch is the topic label lowtide-mirror: pubsub, set through the normal Pub/Sub API on the lowtide topic. So gcloud, Terraform and the console all work. With gcloud pointed at lowtide:
gcloud pubsub topics update orders --project acme --update-labels=lowtide-mirror=pubsubgcloud pubsub topics update orders --project acme --remove-labels=lowtide-mirrorWith Terraform, add or remove labels = { lowtide-mirror = "pubsub" } on the topic (Terraform). Removing the label, or setting another value, switches mirroring off.
The mirror starts from the moment the label is set. Messages published to lowtide before that are not copied. Messages not forwarded yet when the label is removed are not forwarded.
A topic in any project the cluster serves can be mirrored. The target is always the topic with the same name in the same project.
What is sent
Section titled “What is sent”-
Data, attributes and the ordering key, unchanged.
-
Two extra attributes, so consumers can recognize the same message on both sides:
lowtide-origin-message-id: lowtide’s message ID,lowtide-origin-publish-time: when it was published to lowtide (RFC 3339).
If adding them would exceed Pub/Sub’s limits (100 attributes, 10 MB per message), the message goes without them, and
lowtide_mirror_origin_attributes_skipped_totalcounts it. -
The gateway publishes with its own identity (Workload Identity), up to 1,000 messages and 10 MB per request. It needs
roles/pubsub.publisherin the topic’s project (pubsub_mirror_projectsin the module).
Mirroring is not billed as lowtide usage.
Ordering
Section titled “Ordering”Messages with the same ordering key are forwarded strictly in order, one batch per key at a time. A key’s next batch waits for the previous one, and a failed batch is retried as it was. Different keys, and unkeyed messages, go in parallel, up to config.mirror.maxInflight requests per topic and pod.
Pub/Sub keeps ordering only for messages published in the same region. Set config.mirror.pubsubRegion to the region the cluster runs in, so the gateway publishes through that region’s endpoint (https://REGION-pubsub.googleapis.com).
Delivery guarantees
Section titled “Delivery guarantees”- Nothing is dropped while the mirror runs. A message counts as forwarded only once Pub/Sub has accepted it. Until then lowtide keeps it, for up to 7 days.
- Duplicates are possible. When pods join or leave, and in the first seconds after the mirror starts while each pod attaches, a batch in flight can be published twice. The origin attributes identify such duplicates.
Errors and parking
Section titled “Errors and parking”| Error | What the mirror does |
|---|---|
| Network errors, 401, 408, 429, 5xx | Retries with backoff from 250 ms up to 30 seconds, without limit. Logs a warning at most every 30 seconds per topic and pod. Lag grows; nothing is dropped. |
| 400, 403, 404 | Parks: keeps the messages, retries every minute (config.mirror.parkRetryMs), logs a warning at most every 5 minutes and sets lowtide_mirror_parked to 1. It resumes by itself once the cause is fixed. |
When the mirror starts, it checks that the Pub/Sub topic exists and that the gateway may publish to it. If not, it parks right away. The usual causes: the Pub/Sub topic was deleted, or the gateway lacks Pub/Sub Publisher in that project.
A mirror parked for more than 7 days loses its oldest messages.
Watch it
Section titled “Watch it”Per topic and pod: lowtide_mirror_lag_seconds (age of the oldest message not yet forwarded; take the maximum over pods), lowtide_mirror_backlog_messages, lowtide_mirror_forwarded_messages_total, lowtide_mirror_errors_total{kind} and lowtide_mirror_parked (Metrics).
Alert on lowtide_mirror_parked == 1, and on lag above 60 seconds for 5 minutes. The console’s Migration page shows the same per topic and raises the same alerts.
For the whole cluster at once: lowtide-migrate mirror status --topic projects/acme/topics/orders.
Limits
Section titled “Limits”- A message within about 1 KB of Pub/Sub’s 10 MB request limit can’t be published, and the mirror parks on it.
- Messages over about 7.8 MB are sent one at a time over gRPC, because the REST endpoint takes at most 10 MiB per request and base64 adds a third.
- A subscription that is switched to BigQuery or Cloud Storage by an update keeps the shard count it was created with.
How it works inside lowtide
Section titled “How it works inside lowtide”Each mirrored topic gets an internal subscription, created when the label is set and deleted when it is removed. Every pod runs a worker that reads it and publishes to Pub/Sub. The internal subscription uses lowtide’s normal delivery, so it has the same guarantees, and it keeps the topic’s segments from being deleted until they are forwarded.
The internal subscription is not yours to manage: it is not listed by the API, can’t be read, changed or deleted, has no shadow and no subscription metrics of its own.