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

SELECT FOR UPDATE from a secondary index has no effect #88251

Closed
msirek opened this issue Sep 20, 2022 · 1 comment
Closed

SELECT FOR UPDATE from a secondary index has no effect #88251

msirek opened this issue Sep 20, 2022 · 1 comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-qa T-kv KV Team X-duplicate Closed as a duplicate of another issue.

Comments

@msirek
Copy link
Contributor

msirek commented Sep 20, 2022

Describe the problem
If a SELECT ... FOR UPDATE statement happens to scan a secondary index, it does not block other updates.

To Reproduce
In one SQL session:

CREATE TABLE t1 (a int PRIMARY KEY, b int, c int, INDEX c_idx(c));
INSERT INTO t1 SELECT g,g,g FROM generate_series(1,10000) g(g);
ANALYZE t1;

BEGIN;
SELECT * FROM t1 WHERE c = 1 FOR UPDATE;

In another SQL session:

UPDATE t1 SET c=-1 WHERE c = 1;
SELECT * FROM t1 WHERE c = -1;
  a | b | c
----+---+-----
  1 | 1 | -1

Expected behavior
The update statement should block until the first SQL session commits or rolls back. The predicate WHERE c = 1 causes a scan of index c_idx, but if the primary index is scanned, the update blocks.

Jira issue: CRDB-19748

@msirek msirek added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team labels Sep 20, 2022
@msirek msirek added the O-qa label Sep 27, 2022
@blathers-crl blathers-crl bot added the T-kv KV Team label Sep 30, 2022
@rytaft rytaft removed their assignment Sep 30, 2022
@michae2
Copy link
Collaborator

michae2 commented Mar 18, 2024

Closing this as a duplicate of #57031. This is fixed in 23.2 when using the new SFU implementation (optimizer_use_lock_op_for_serializable).

@michae2 michae2 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
@michae2 michae2 added the X-duplicate Closed as a duplicate of another issue. label Mar 18, 2024
@exalate-issue-sync exalate-issue-sync bot removed X-duplicate Closed as a duplicate of another issue. T-sql-queries SQL Queries Team labels Mar 18, 2024
@michae2 michae2 added the X-duplicate Closed as a duplicate of another issue. label Mar 18, 2024
@github-project-automation github-project-automation bot moved this to Closed in KV Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-qa T-kv KV Team X-duplicate Closed as a duplicate of another issue.
Projects
Archived in project
Status: Closed
Development

No branches or pull requests

3 participants