cockroachdb / cockroachdb/cockroach
changefeed with diff option produces phantom deletes.
- 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
Assessment
This issue has not been assessed yet.