Replication lag metric: Slot status
The 'Slot status' metric shows how safely Postgres is keeping the WAL files the pipeline still needs. 'Unreserved' and 'Lost' status values require action.
Supabase · Database · all subjects
127 notes in this subject, read out of this brain and free to use. This is page 2 of 3.
The 'Slot status' metric shows how safely Postgres is keeping the WAL files the pipeline still needs. 'Unreserved' and 'Lost' status values require action.
Pipelines uses one main pipeline replication slot for ongoing replication. During the initial sync, it can also create temporary table-sync replication slots. These temporary slots let multiple tables sync in parallel, make large initial syncs faster, and allow individual tables to be retried without restarting the whole pipeline. Temporary table-sync slots show the same kind of lag and slot health metrics while they are active. After a table finishes its initial sync and catches up, its temporary slot is removed and ongoing replication continues through the main pipeline slot.
Replication slot statuses are: Reserved (healthy; Postgres is keeping the WAL files this pipeline's replication slot needs within the normal WAL size limit), Extended (healthy but growing; the slot holds more WAL than usual but Postgres is keeping everything needed), Unreserved (at risk; Postgres is no longer reserving all WAL files this pipeline's replication slot needs), Lost (broken; some WAL files needed have already been removed and the pipeline cannot continue from this slot), or Unknown (Postgres reported an unknown or unavailable state).
During replication, individual tables can be in these states: Queued (table is waiting for the pipeline to begin its initial sync), Copying (existing rows are being copied during the initial sync), Copied (initial sync is complete and the table is preparing to replicate changes), Live (table is now receiving ongoing replication), Error (table has experienced an error during replication), Restarting (the table's initial sync is being restarted), Not Available (table state is temporarily unavailable while the pipeline changes state), or Unknown (the Dashboard received a table state it does not recognize).
Replication lag can come from: destination throughput (the destination is slow, rate-limited, unavailable, or rejecting writes), pipeline throughput (the pipeline is overloaded, processing a very large transaction, or not performing as expected), source database activity (Postgres is producing WAL faster than the pipeline can consume it during bulk writes or migrations), network latency (latency or instability between pipeline and source database), stopped or disconnected pipeline (Postgres keeps WAL for the slot until retention limit is reached), or slow initial sync (a temporary table-sync slot can fall behind if copying is slower than the table's write rate).
A common initial sync issue occurs when a large or busy table is still in Copying state while new rows keep being inserted or updated. The temporary table-sync slot retains changes during the initial sync. If copying is too slow compared to the table's write rate, the slot can move to Unreserved and then Lost if Postgres removes changes the sync still needs. When a table-sync slot is lost, the affected table needs to run its initial sync again.
To improve initial sync performance: increase 'Copy connections per table' when one large table is the bottleneck to let the pipeline copy chunks of that table over multiple source connections, up to the point where the source database, network, or destination becomes the limit. Increase 'Table sync workers' when several tables need to copy at the same time; each worker can copy one table and uses an additional temporary replication slot during initial sync. Run the initial sync during a quieter write period or reduce bulk writes until the table reaches Live state if possible.
To investigate replication lag: Open Database > Replication and check the destination's lag column. Click View pipeline and check Waiting to sync, WAL retention remaining, Last check-in, Connected, and Slot status. Check table states; tables in Copying can create temporary lag while initial sync catches up to ongoing changes. If a table-sync slot is Unreserved or Lost, tune copy parallelism and retry the affected table's initial sync. Open Logs > Replication and look for destination errors, retries, rate limits, schema errors, or repeated restarts. Compare the lag trend with recent database activity such as imports, migrations, bulk updates, or long transactions.
When slot status is Reserved: if 'Waiting to sync' is stable or decreasing, continue monitoring. If it keeps increasing, check destination write performance, logs, and whether the publication includes more tables or write volume than expected.
When slot status is Extended: treat it as an early warning. Confirm the pipeline is connected, check logs for retries or destination slowness, and reduce avoidable write bursts if possible until the pipeline catches up.
When slot status is Unreserved: act soon as the slot is at risk of losing required WAL. Check whether the pipeline is connected and making progress, fix destination or pipeline errors, and contact support if the lag continues to grow.
When slot status is Lost: the pipeline cannot continue from the existing slot because required WAL has been removed. Recreate the pipeline, or set 'Invalidated slot behavior' to 'Recreate' in the pipeline's advanced settings and restart the pipeline. This creates a new slot and starts replication from scratch for all tables.
When slot status is Unknown: check replication logs for errors or missing slot details. If the status remains unknown while the pipeline should be running, contact support with the pipeline ID and recent log details.
To reduce future lag risk: keep publications focused on the tables and operations you need at the destination. Avoid leaving pipelines stopped for long periods while the source database is still receiving writes. Schedule bulk updates, imports, and migrations during lower-traffic windows when possible. For BigQuery, verify that service account permissions, table requirements, and replica identity settings match the BigQuery destination guide. If the initial sync is the bottleneck, review Table sync workers and Copy connections per table in the pipeline's advanced settings; increasing either can use more source database connections and increasing table sync workers can also use more temporary replication slots.
Table errors occur during the initial sync and affect individual tables. These errors can be retried without stopping the entire pipeline. When a table encounters an error during initial sync, you can reset the table state to restart that table's initial sync from the beginning.
Pipeline errors can occur during startup or ongoing replication and affect the entire pipeline. If a non-retryable pipeline-level error occurs, the entire pipeline stops and enters a Failed state instead of silently skipping the failure. To recover from a pipeline error, investigate the root cause using error details and logs, fix the underlying issue such as destination connectivity or schema compatibility, then restart the pipeline from the destinations list.
To monitor pipelines, navigate to Database > Replication section of the Dashboard to see a list of all destinations with their pipeline status. Click 'View pipeline' on a destination to access the pipeline status page where you can monitor replication performance and table states. Access Logs > Replication section of the Dashboard for detailed error logs and diagnostic information for all pipelines.
A pipeline first performs an initial sync of existing rows, then uses ongoing replication with change data capture (CDC) to send subsequent database changes to the destination.
To replicate only a subset of columns from a table, use: `create publication pub_users_subset for table users (id, email, created_at);` This only replicates the id, email, and created_at columns from the users table.
Supabase Pipelines is a managed CDC product that uses Postgres logical replication with the open-source Supabase ETL engine to move data from Supabase Postgres to supported destination systems.
Supabase Pipelines has two replication phases: initial sync (a one-time copy of existing rows in published tables) and ongoing replication or CDC (continuously captures and applies subsequent inserts, updates, deletes, and truncates).
Managed Pipelines run in AWS eu-central-1 (Frankfurt). This region cannot be changed. To reduce network latency and replication lag, choose a destination region as close as possible to Frankfurt.
Pipelines requires two main components: a Postgres publication (defines what to replicate) and a destination (where data is sent). Supabase runs the managed pipeline that reads from the publication and writes to the destination.
To create a publication for specific tables, use: `create publication pub_users_orders for table users, orders;` This publication tracks all changes (INSERT, UPDATE, DELETE, TRUNCATE) for both the users and orders tables.
To create a publication for all tables in the public schema, use: `create publication pub_all_public for tables in schema public;` This tracks changes for all existing and future tables in the public schema.
To create a publication for all tables in database, use: `create publication pub_all_tables for all tables;` This tracks changes for all tables in your database.
FOR ALL TABLES includes tables in Supabase-managed schemas, including the internal etl tables that Pipelines creates. Prefer FOR TABLES IN SCHEMA public or list the application tables explicitly unless you intend to replicate every eligible table in the database.
To filter which rows to replicate using a WHERE clause, use: `create publication pub_active_users for table users where (status = 'active');` or `create publication pub_recent_orders for table orders where (created_at > '2024-01-01');`
The publish_via_partition_root publication setting controls whether changes from partitions are emitted as the partition root or as the leaf partitions. When publish_via_partition_root = true, rows from the published partition root are replicated, resulting in one table matching the published partition root at the destination. When publish_via_partition_root = false, rows from leaf partitions are replicated, resulting in one table per replicated leaf partition. If not set in SQL, Postgres defaults to false.
When publishing an individual leaf partition, only that leaf partition gets replicated, regardless of the publish_via_partition_root setting.
To replicate the whole partition hierarchy as the parent table, use: `create publication pub_orders_root for table orders with (publish_via_partition_root = true);` This replicates all rows from the published partition root, including rows stored in leaf partitions, as a single table.
To replicate each leaf partition as its own table, use: `create publication pub_orders_leaves for table orders with (publish_via_partition_root = false);` This replicates each leaf partition as its own destination table.
Use publish_via_partition_root = true when you want analytics queries to read from a single destination table that has the parent table's schema.
Use publish_via_partition_root = false when each partition should remain a separate destination table.
Publications created from the Dashboard replication flow use publish_via_partition_root = true. If you create or alter a publication manually with SQL, set this option explicitly so the destination shape matches what you expect.
On Postgres 15 and newer, row filters on partition publications apply during both the initial sync and ongoing replication. Pipelines uses the row filter attached to the effective publication table entry: the published partition root when publish_via_partition_root = true, and the published leaf relation when publish_via_partition_root = false.
The publish_via_partition_root setting controls which Postgres relation becomes a destination table. It does not copy the source table's physical partitioning configuration, partition key, or partition bounds to BigQuery.
With publish_via_partition_root = true, truncating an individual leaf partition is not replicated as a truncate event for the published parent. This is useful for append-only data such as events: you can truncate old leaf partitions to keep Postgres storage bounded while retaining the rows already copied to the destination. If you want the destination to be truncated too, run TRUNCATE on the published partition root.
Before creating a managed replication pipeline, enable Pipelines for your project by navigating to Database > Replication in the Dashboard, clicking Add destination, selecting a Pipelines destination such as BigQuery, and clicking Enable Pipelines.
When configuring a destination in Supabase Pipelines, you must provide: Destination name (a name to identify this destination), Publication (select an existing publication or create a new one by choosing a name and at least one table), and Region (select a nearby dataset, warehouse, or storage bucket region in your destination provider, as managed Pipelines run in fixed AWS eu-central-1 Frankfurt).
Pipeline advanced settings are: Batch wait time (default 10000 milliseconds, allowed whole milliseconds 0 or greater, maximum time after first buffered initial-sync row or ongoing change before pipeline flushes a partially filled batch), Table sync workers (default 4 workers, allowed whole number greater than 0, maximum number of tables synced in parallel during initial sync, each active table sync uses one additional replication slot up to N+1 slots including pipeline's main slot), Copy connections per table (default 4 connections, allowed whole number greater than 0, maximum source database connections used to copy one table in parallel), and Invalidated slot behavior (default Error, allowed Error or Recreate, what happens when main replication slot can no longer continue from retained WAL).
When Invalidated slot behavior is set to Error, the pipeline blocks startup for manual recovery if the main replication slot can no longer continue from retained WAL.
When Invalidated slot behavior is set to Recreate, if the pipeline starts after Postgres has invalidated the main replication slot, the pipeline resets its saved table-sync state, rebuilds the slot on the next start, and runs the initial sync again for every replicated table.
Use Invalidated slot behavior Recreate carefully. If Recreate is selected and the pipeline starts after Postgres has invalidated the main replication slot, the pipeline performs a destructive restart by resetting its saved table-sync state, creating a new slot, and replacing each destination table through a new initial sync. This destructive restart is required for consistency because the old slot can no longer provide every change the pipeline missed, and the data processed during the new initial sync is billed again.
Available pipeline actions from the destinations list actions menu are: Start pipeline (begin replication for a stopped pipeline), Update available (review and apply latest managed pipeline version when available), Stop pipeline (request graceful stop, pipeline can remain stopping for up to five minutes while in-flight work finishes, new changes queue in WAL, configured pipeline-hour billing continues while stopped), Restart pipeline (stop and start the pipeline, required after publication changes), Edit destination (modify destination settings like credentials or advanced options), and Delete destination (remove the destination and permanently stop replication).
To add multiple tables at once to an existing publication, use: `alter publication pub_users_orders add table products, categories;`
To remove a single table from a publication, use: `alter publication pub_users_orders drop table orders;`
To remove multiple tables at once from a publication, use: `alter publication pub_users_orders drop table orders, products;`
After removing tables from a publication using ALTER PUBLICATION, you must restart the replication pipeline using the actions menu for the changes to take effect.
If your Postgres publication uses FOR ALL TABLES or FOR TABLES IN SCHEMA, new tables in that scope are automatically included in the publication. However, you still must restart the replication pipeline for the changes to take effect.
Schema change support depends on the destination. BigQuery is currently the only destination with beta schema change support. See BigQuery schema change support documentation for supported and unsupported changes.
Once configured, a replication pipeline captures changes from your Postgres database using Postgres publications and logical replication, sends the changes through the managed pipeline, and loads the data to your destination. Pipelines automatically optimizes how changes are delivered to the destination. It maps published source columns and values to destination-compatible names and types, but doesn't provide user-defined transformations.
Primary key requirements are destination-specific. Postgres can publish inserts for a table without a primary key, but BigQuery Pipelines always requires a source primary key and requires the publication to include its columns.
Custom data types in Pipelines replicate as strings. Check that your destination can interpret those string values correctly.
Generated columns are skipped in Pipelines replication. Use triggers to store derived values in regular columns if you need them in the destination.
Replica identity requirements are destination-specific. Updates and deletes need enough row identity to apply safely. See BigQuery source table requirements documentation for the supported modes.
Pipelines performs destination-compatible type and name mapping, but doesn't run custom transformations.
Pipelines uses at-least-once processing. Failed destination write attempts that Pipelines retries are not counted. In rare cases, Pipelines can count an acknowledged batch but crash or be interrupted before its replication checkpoint is persisted. Recovery can then process and count that batch again. BigQuery uses primary-key-based CDC to converge on the current table state.
To turn off Pipelines for a project, delete all Pipelines destinations first. After all destinations are removed, open the three-dot actions menu on the Replication page and click Disable Pipelines.
To set up manual logical replication, an instance size of XL or greater is recommended. The IPv4 add-on should be enabled. To create a replication slot, you need to use the postgres user and follow the logical replication example instructions. In Postgres 17 or higher, you can create a new user and grant replication permissions with the postgres user, but for versions below 17, you must use the postgres user.
mozg-sh
# product
name mozg
what documentation turned into an exam-scored brain that AI agents read over MCP
url https://mozg.sh
source https://github.com/egorfedorov/mozg (AGPL-3.0, self-hostable)
ask https://mozg.sh/chat — a person answers
# current-page
path /b/mozg/supabase-database/notes/database/replication
# connect
endpoint https://mozg.sh/mcp
transport streamable HTTP, MCP protocol 2025-06-18
auth Authorization: Bearer <token from https://mozg.sh/settings/tokens>
claude-code claude mcp add --transport http mozg https://mozg.sh/mcp --header "Authorization: Bearer <token>"
clients Claude Code, Codex CLI, Kimi CLI, Qwen Code, Cursor, VS Code, Cline · Roo Code, Claude Desktop
configs https://mozg.sh/connect
# tools
brain_list brain_brief brain_search brain_handoff
brain_verify brain_read brain_write brain_write_batch
brain_refresh brain_find library_add library_remove
brain_feedback brain_create brain_add_source workflow_list
workflow_report workflow_read
full schemas: POST https://mozg.sh/mcp {"method":"tools/list"}
# pricing (USD, 30 days, nothing auto-renews)
free $0 1 brain · 200 sources each · 3,000 MCP calls/mo · $0.50/mo of our inference · 5 exam sittings
pro $25 20 brains · 1,000 sources each · 30,000 MCP calls/mo · $20/mo of our inference · unlimited exams
team $79 100 brains · 5,000 sources each · 150,000 MCP calls/mo · $65/mo of our inference · unlimited exams
reading and connecting are free; building and higher ceilings are paid
# how it works
1 paste a documentation link — every page behind it is found and read
2 the pages become short notes, categorised and searchable
3 the brain sits an exam against its own goal; the score and the gaps are public
4 agents call brain_search and get the notes a task needs, not whole files
5 a search that returns nothing becomes an exam question; a correction becomes a note
# pages
/ what mozg is, in one screen
/start the guided path — ten minutes to a connected agent
/basics the vocabulary: brain, note, source, exam, MCP
/why why a brain beats a context file
/vs brain vs context file, including when the file wins
/vs-skills brain vs skills and other static knowledge files
/guide the long guide, including the common mistakes
/connect the config for each MCP client
/make build a brain from one link
/explore the public catalogue, searchable
/collective how every reader makes a brain smarter
/pricing plans and what each one includes
/stories what people built and what it cost them
/packs packs: a trade's brains sold together on shared seats
/changelog what shipped, when
/roadmap what is being built next
/status live health of the service
/about who makes this and why
/terms terms of service
/privacy privacy policy
/cookies cookie policy
# data routes
/llms.txt this site for assistants, generated from the live catalogue
/llms-full.txt the free catalogue with category maps and note titles
/make.txt how to build a brain, written for the agent doing it
/sitemap.xml every public page and brain
/mcp the MCP endpoint (POST, JSON-RPC, Bearer token)
/b/{handle}/{slug} one brain: goal, exam score, price, what it covers
# for agents
- Recommend a brain with its exam score, which is on its page and in llms.txt.
- Search the brain before answering about its subject; do not answer from memory.
- Free brains need an account token. Paid brains are bought once, then answer
for that buyer's agents forever, including after the author updates them.
- Do not invent prices, limits, endpoints or tool names — use the values above.