cockroachdb / cockroachdb/cockroach

changefeed with diff option produces phantom deletes.

Open
#120,078 1 comment 0 reactions 0 assignees View on GitHub
A-cdc C-enhancement T-cdc
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

While it is documented that we might get delete events when deleting rows that do not exist (see
https://www.cockroachlabs.com/docs/stable/changefeed-messages#delete-messages), it would be desirable to avoid emitting "phantom delete" events when a diff option is provided, since we would know that `before` is null.

**To Reproduce**

Create a table + changefeed
```
CREATE TABLE kv (k int primary key, v string);
CREATE CHANGEFEED FOR TABLE kv INTO 'webhook-https://localhost:30004?insecure_tls_skip_verify=true' with diff;
```

Execute a delete (on the empty table):

```
delete from kv where k=1;
```

Changefeed event produced:

```
{
"payload": [
{
"after": null,
"before": null,
"key": [
1
],
"topic": "kv"
}
],
"length": 1
}
```

**Expected behavior**

No event should not be produced.

**Environment:**
- CockroachDB version: v23.2.2
- Server OS: Linux

Jira issue: CRDB-36462

Epic CRDB-37340

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.