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 doesn't seem to work on views in some cases #21335

Open
zyguan opened this issue Nov 26, 2020 · 2 comments
Open

select for update doesn't seem to work on views in some cases #21335

zyguan opened this issue Nov 26, 2020 · 2 comments
Assignees
Labels
severity/minor sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@zyguan
Copy link
Contributor

zyguan commented Nov 26, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

/* init */ drop table if exists t;
/* init */ drop view if exists v;
/* init */ create table t(a int primary key, b int);
/* init */ create view v as select a, b from t;
/* init */ insert into t values(1,2),(2,3);

/* t1 */ begin;
/* t2 */ begin;
/* t1 */ update t set b = 12 where a = 1;
/* t2 */ select * from v where a < 2 for update; -- range-scan on view, not blocked
# /* t2 */ select * from v where a = 1 for update; -- point-get on view, blocked
# /* t2 */ select * from t where a < 2 for update; -- range-scan on table, blocked
# /* t2 */ select * from t where a = 1 for update; -- point-get on table, blocked
/* t1 */ commit;
/* t2 */ commit;

2. What did you expect to see? (Required)

select * from v where a < 2 for update; should be blocked by t1.

3. What did you see instead (Required)

It's not blocked.

4. What is your TiDB version? (Required)

release-4.0 (1e73c51)

@zyguan zyguan added the type/bug The issue is confirmed as a bug. label Nov 26, 2020
@ghost
Copy link

ghost commented Nov 27, 2020

Because views are non-writeable in TiDB, the expected behavior should be an error when trying FOR UPDATE or LOCK IN SHARE MODE.

@qw4990 qw4990 added sig/transaction SIG:Transaction and removed sig/execution SIG execution labels Dec 1, 2020
@qw4990
Copy link
Contributor

qw4990 commented Dec 1, 2020

PTAL @cfzjywxk @lysu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/minor sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants