Abstract

A query-result cache that keeps itself consistent with a PostgreSQL origin database by consuming the origin's logical replication stream normally holds one replication slot per cache instance. Slots are decoded separately on the origin, each pins write-ahead log until its consumer acknowledges, and a slot whose consumer has died retains log indefinitely. This limits a deployment to a handful of caches per origin and rules out short-lived or edgelocated caches. This disclosure describes a fan-out replication server that holds the single slot, retains the decoded stream in a durable log whose records carry origin log sequence numbers (LSNs), and serves any number of downstream caches over the same replication protocol the origin speaks, so that a cache cannot tell the server from the origin. Each consumer has its own acknowledged position, expressed as an origin LSN, which the server expires when the consumer disappears; each consumer declares the set of relations it needs, which it may change while connected, and the server filters the stream per consumer. Unlike eventually-consistent sinks, a cache depends on source-transaction boundaries and commit LSNs for its consistency watermarks, so the server preserves BEGIN and COMMIT framing through filtering and delivers a transaction that filters to nothing as a position mark carrying its commit LSN. Schema and control messages pass through to every consumer whose relations they touch. The single slot may live on a standby.

Creative Commons License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 License.

Share

COinS