ETLMCPData Conveyance Works
Log in Start free
Docs

'cannot delete from table … replica identity': etlmcp tables in a publication

Why a PostgreSQL load fails with a replica identity error when the database publishes changes, and how to fix it with a schema, database or table setting.

If a PostgreSQL load fails with cannot delete from table "<table>" because it does not have a replica identity and publishes deletes, your database has a publication that covers etlmcp's table. PostgreSQL refuses a DELETE or UPDATE on a published table unless that table has a replica identity, and the table etlmcp creates has none. A run that delivers rows deletes before it inserts, so those runs fail. The fix is to keep the table out of the publication, or to give it a replica identity.

Why the load is refused

A publication lists the tables whose changes PostgreSQL sends to subscribers. When a publication sends deletes or updates, the subscriber needs a way to find the changed row, and that is the table's replica identity. By default it is the primary key. You can also point it at a suitable unique index, or set it to FULL, which uses the whole row. A table with none of these may still take INSERTs, but a DELETE or UPDATE on it fails.

etlmcp creates its table with one column per field it delivers plus _etlmcp_pipeline_id, and no primary key. Each load then deletes this pipeline's rows for the run's dates and inserts the new rows, all in one transaction (see how row replacement works). The DELETE is where PostgreSQL stops. etlmcp reports the server's message after database error: {…}, so the run shows:

database error: cannot delete from table "<table>" because it does not have a replica identity and publishes deletes

Why the table is in a publication you never touched

A publication made with FOR ALL TABLES covers every table in the database, including tables created later. One made with FOR TABLES IN SCHEMA covers every table in those schemas, including later ones. So when etlmcp creates a new table in a covered schema, it joins the publication at once. Change data capture and replication tools often set up publications like these. Supabase's Pipelines setup guide, for example, shows a publication for all tables in the public schema, and public is etlmcp's default schema.

Why the Test button passes

The Test button creates the table if it is missing, inserts one sample row and rolls everything back. INSERT is allowed on a published table without a replica identity, so the test succeeds. A real run fails at its DELETE, and because the whole load is one transaction, the failed run rolls back too, including the CREATE TABLE. That is why you will not find the table afterwards.

How to fix it

Pick one:

  • Use a schema the publication does not cover. Set the destination's Schema field to a schema outside a FOR TABLES IN SCHEMA publication. This does not help with FOR ALL TABLES.
  • Use another database. A publication belongs to the database it was created in, so a database with no publication avoids the problem.
  • Create the table yourself, then set a replica identity. Run ALTER TABLE <schema>.<table> REPLICA IDENTITY FULL;. Deletes then work, and the deleted rows are sent to subscribers in full. PostgreSQL's documentation calls FULL a last resort because subscribers may search slowly without a suitable index.
  • Exclude the table from an all-tables publication (PostgreSQL 19). ALTER PUBLICATION <name> SET ALL TABLES EXCEPT (TABLE <schema>.<table>); replaces the publication's exclusion list, so name every table it already excludes. It needs superuser rights, and a subscriber must refresh its subscription for the change to apply. The table must exist first.

Creating the table yourself

etlmcp only writes to a table that has a _etlmcp_pipeline_id column; any other existing table is refused. Create it with:

  • _etlmcp_pipeline_id as text NOT NULL;
  • date as date;
  • each metric as double precision;
  • every other column as text.

The table needs every column the pipeline delivers. A missing column fails the run with a list of the names, except platform extras, which etlmcp adds itself when it owns the table. The PostgreSQL destination errors page lists those messages.

Related

Sources

  1. 29.1. Publication — www.postgresql.org, checked
  2. CREATE PUBLICATION — www.postgresql.org, checked
  3. ALTER PUBLICATION — www.postgresql.org, checked
  4. Set up Pipelines — supabase.com, checked
  5. execReplication.c — raw.githubusercontent.com, checked