Skip to content

sql: elevated number of rows affected returned for DeleteRange with multiple column families #151505

@yuzefovich

Description

@yuzefovich

This bug has been present for a long time (it was added in 807c1f2 around 19.2 version) and was exposed via #151500.

We paginate DelRange requests by setting MaxSpanRequestKeys limit of 600. For each KV batch we count how many rows were actually deleted. If we happen to hit the limit in the middle of a SQL row (one KV batch deletes some KVs of a row and the next KV batch deletes the remaining KVs), we'll count this single row as two in the "rows affected" calculation.

Here is an example that demonstrates it:

CREATE TABLE t (
  k INT PRIMARY KEY,
  c INT,
  FAMILY (k),
  FAMILY (c)
);
-- insert 600 rows total
INSERT INTO t SELECT i, NULL FROM generate_series(1, 599) AS g(i);
INSERT INTO t VALUES (600, 2);
-- delete 600 rows, but 601 is reported
DELETE FROM t WHERE k > 0 AND k < 1000;
-- DELETE 601

Jira issue: CRDB-53317

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries Teambranch-release-20.1Used to mark GA and release blockers, technical advisories, and bugs for 20.1target-release-25.4.0

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions