cockroachdb / cockroachdb/cockroach

cdc: deletion events for tables whose primary key includes a composite types is invalid

Open
#127,315 7 comments 0 reactions 0 assignees View on GitHub
A-cdc branch-master C-bug P-3 T-cdc
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

Composite types such as collated strings store their data in the Value of the row's underlying KV even when that column is in the primary key. Deletion events from the rangefeed, however have a nil value. As a result, the changefeed does not correctly decode the key. For instance, consider the following table:

```
CREATE TABLE rand_table (col STRING COLLATE en_US PRIMARY KEY);
```

with a changefeed running on it:

```
create changefeed for rand_table with envelope=key_only;
```

The following two operations on the same key

```
INSERT INTO rand_table VALUES (e'\U00023540\U0003163B\U000A4ADE\U000371E1\U00022F0E\U0000970A\U000E74B6\U0007A326\U000B1CD6' COLLATE en_US);
DELETE FROM rand_table LIMIT 1;
```

Produce very different key's in the encoded value:

```
{"key":"[\"\\360\\243\\225\\200\\360\\261\\230\\273\\362\\244\\253\\236\\360\\267\\207\\241\\360\\242\\274\\216\\351\\234\\212\\363\\247\\222\\266\\361\\272\\214\\246\\362\\261\\263\\226\"]","table":"rand_table","value":""}
{"key":"[\"\\\\ufffd5@\\\\ufffd\\\\u0016;\\\\ufffdJ\\336\\210q\\\\ufffd\\\\ufffd/\\\\u000e\\\\ufffd\\\\ufffd\\\\n\\\\ufffdt\\\\ufffd\\\\ufffd\\\\ufffd\u0026\\\\ufffd\\\\u001c\\\\ufffd\\\\u0000\\\\u0000\\\\u0000 \\\\u0000 \\\\u0000 \\\\u0000 \\\\u0000 \\\\u0000 \\\\u0000 \\\\u0000 \\\\u0000 \\\\u0000\\\\u0000\\\\u0002\\\\u0002\\\\u0002\\\\u0002\\\\u0002\\\\u0002\\\\u0002\\\\u0002\\\\u0002\"]","table":"rand_table","value":""}
```

Jira issue: CRDB-40368

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.