Skip to content

TRUNCATE Is Invisible To CDC Subscriptions #30

Description

@oskoi

disclaimer: I ran audit using codex-gpt5.5 and found critical issue with reproduce. Feel free to close if you think it's not critical 🙌

TRUNCATE removes all table rows by replacing partition heaps at commit time. It logs DDL for recovery, but it does not emit delete events or any explicit truncate CDC event. A CDC consumer that has acknowledged the prior writes sees an empty stream while the table has been destructively changed.

open E0 "uuid": "00000000-0000-0000-0000-000000000000", "listen": [{ "host": "127.0.0.1", "port": 3485 }];
connect E0 S0 127.0.0.1:3485;

create table test (id int primary key, data int);
create subscription test_sub on test;
insert into test values (1, 10), (2, 20);
acknowledge test_sub to 3, 1;

truncate test;

select * from test_sub;
select * from test order by id;

disconnect S0;
close E0;

Expected correct result:

The stream reports the destructive change, either as delete events for the
removed rows or as an explicit truncate event, or TRUNCATE is rejected while a
CDC subscription exists.

Observed bad result:

The table is empty, but the subscription has no event for the committed
destructive change:

select * from test_sub;

lsn  lsn_op  cmd  row
-----------------------

select * from test order by id;

id  data
----------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions