Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql/row: not deleting single-column family of composite column when updating with non-composite value #131860

Closed
michae2 opened this issue Oct 3, 2024 · 0 comments · Fixed by #131869
Assignees
Labels
branch-master Failures and bugs on the master branch. branch-release-22.2 Used to mark GA and release blockers, technical advisories, and bugs for 22.2 branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 branch-release-24.3 Used to mark GA and release blockers, technical advisories, and bugs for 24.3 C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-erroneous-edge-case Database produces or stores erroneous data without visible error/warning, in rare edge cases. T-sql-queries SQL Queries Team

Comments

@michae2
Copy link
Collaborator

michae2 commented Oct 3, 2024

This is pretty niche, but this continue should sometimes be an if branch over MarshalLegacy if the reason we're skipping is because a value is non-composite:

Here's an example:

CREATE TABLE abc (a INT NOT NULL, b FLOAT NOT NULL, c INT, FAMILY (a), FAMILY (b), FAMILY (c));
-- note that -0::float is a composite value if b becomes part of the PK
INSERT INTO abc VALUES (4, -0, 6);
-- make b part of the PK
ALTER TABLE abc ADD PRIMARY KEY (a, b);
-- for example, this deletes the c column family KV as it should
UPDATE abc SET c = NULL WHERE a = 4 AND b = -0;
-- but this does not delete the b column family KV when b is no longer a composite value
UPDATE abc SET b = 0 WHERE a = 4 AND b = -0;
-- so now this still shows -0 (the composite value)
SELECT * FROM abc;

Looks like this was introduced in v22.2 from 5dff0e5

Jira issue: CRDB-42727

@michae2 michae2 added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-erroneous-edge-case Database produces or stores erroneous data without visible error/warning, in rare edge cases. branch-master Failures and bugs on the master branch. T-sql-queries SQL Queries Team branch-release-22.2 Used to mark GA and release blockers, technical advisories, and bugs for 22.2 branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 branch-release-24.3 Used to mark GA and release blockers, technical advisories, and bugs for 24.3 labels Oct 3, 2024
@michae2 michae2 self-assigned this Oct 3, 2024
@github-project-automation github-project-automation bot moved this to Triage in SQL Queries Oct 3, 2024
@michae2 michae2 moved this from Triage to Active in SQL Queries Oct 3, 2024
michae2 added a commit to michae2/cockroach that referenced this issue Oct 4, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860
Informs: cockroachdb#131645

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family
writes an incorrect value to the primary index. This bug has existed
since v22.2.
craig bot pushed a commit that referenced this issue Oct 4, 2024
131869: sql/row: fix updates of single-composite-column families r=stevendanna a=michae2

When updating a single-column family which contains what could be a composite value from the primary key, we still need to issue a Del even if the new value for the column is not composite, because the previous value might have been composite.

Fixes: #131860
Informs: #131645

Release note (bug fix): Fix a rare bug in which an update of a primary key column which is also the only column in a separate column family can sometimes fail to update the primary index. This bug has existed since v22.2.

Co-authored-by: Michael Erickson <[email protected]>
@craig craig bot closed this as completed in 1672db9 Oct 4, 2024
@github-project-automation github-project-automation bot moved this from Active to Done in SQL Queries Oct 4, 2024
michae2 added a commit to michae2/cockroach that referenced this issue Oct 7, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 7, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 7, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
This helps show what is happening.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
This helps show what is happening.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
This helps show what is happening.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
This helps show what is happening.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 8, 2024
This helps show what is happening.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 9, 2024
This helps show what is happening. Also make the kvtrace option handle
keys with tenant prefixes.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 10, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 10, 2024
This helps show what is happening. Also make the kvtrace option handle
keys with tenant prefixes.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 10, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 10, 2024
This helps show what is happening. Also make the kvtrace option handle
keys with tenant prefixes.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 10, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 10, 2024
This helps show what is happening. Also make the kvtrace option handle
keys with tenant prefixes.

Informs: cockroachdb#131860

Release note: None
michae2 added a commit to michae2/cockroach that referenced this issue Oct 10, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 10, 2024
This helps show what is happening. Also make the kvtrace option handle
keys with tenant prefixes.

Informs: cockroachdb#131860

Release note: None
craig bot pushed a commit that referenced this issue Oct 14, 2024
132204: logictest: add kv tracing to testcase for 131869 r=mgartner a=michae2

This helps show what is happening. Also make the kvtrace option handle keys with tenant prefixes.

Informs: #131860

Release note: None

Co-authored-by: Michael Erickson <[email protected]>
michae2 added a commit to michae2/cockroach that referenced this issue Oct 16, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 16, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 16, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
michae2 added a commit to michae2/cockroach that referenced this issue Oct 16, 2024
When updating a single-column family which contains what could be a
composite value from the primary key, we still need to issue a Del even
if the new value for the column is not composite, because the previous
value might have been composite.

Fixes: cockroachdb#131860

Release note (bug fix): Fix a rare bug in which an update of a primary
key column which is also the only column in a separate column family can
sometimes fail to update the primary index. This bug has existed since
v22.2. Requirements to hit the bug are:

1. A table with multiple column families.
2. A column family containing a single PK column.
3. That column family is not the first column family.
4. That column family existed before its column was in the PK.
5. That column must be of type FLOAT4/8, DECIMAL, JSON, collated string
   type, or array.
6. An update that changes that column from a composite value to a non-
   composite value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch-master Failures and bugs on the master branch. branch-release-22.2 Used to mark GA and release blockers, technical advisories, and bugs for 22.2 branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 branch-release-24.3 Used to mark GA and release blockers, technical advisories, and bugs for 24.3 C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-erroneous-edge-case Database produces or stores erroneous data without visible error/warning, in rare edge cases. T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant