-
Notifications
You must be signed in to change notification settings - Fork 480
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
PS-9297 Lost a record while scanning in reverse order on cursor #5348
Open
zhry110
wants to merge
1
commit into
percona:release-8.0.37-29
Choose a base branch
from
zhry110:release-8.0.37-29
base: release-8.0.37-29
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
create table c(id int primary key, val varchar(8000)); | ||
insert into c values (1,repeat('a',3000)); | ||
insert into c values (2,repeat('a',3000)); | ||
insert into c values (3,repeat('a',3000)); | ||
insert into c values (4,repeat('a',3000)); | ||
insert into c values (5,repeat('a',3000)); | ||
insert into c values (-1,repeat('a',2000)); | ||
insert into c values (-2,repeat('a',2000)); | ||
insert into c values (-3,repeat('a',2000)); | ||
insert into c values (-4,repeat('a',2000)); | ||
insert into c values (-5,repeat('a',2000)); | ||
select id,length(val) from c order by id desc; | ||
id length(val) | ||
5 3000 | ||
4 3000 | ||
3 3000 | ||
2 3000 | ||
1 3000 | ||
-1 2000 | ||
-2 2000 | ||
-3 2000 | ||
-4 2000 | ||
-5 2000 | ||
set DEBUG="+d,desc_scan_debug"; | ||
set DEBUG_SYNC="desc_scan_before_restore_position SIGNAL desc_scan_before_restore_position_done WAIT_FOR continue"; | ||
select id,length(val) from c order by id desc; | ||
set DEBUG_SYNC="now WAIT_FOR desc_scan_before_restore_position_done"; | ||
update c set val=repeat('b',6000) where id=2; | ||
set DEBUG_SYNC="now SIGNAL continue"; | ||
id length(val) | ||
5 3000 | ||
4 3000 | ||
3 3000 | ||
2 3000 | ||
1 3000 | ||
-1 2000 | ||
-2 2000 | ||
-3 2000 | ||
-4 2000 | ||
-5 2000 | ||
set DEBUG="-d,desc_scan_debug"; | ||
drop table c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--source include/have_debug.inc | ||
|
||
connect (con1, localhost, root,,); | ||
--connection default | ||
create table c(id int primary key, val varchar(8000)); | ||
insert into c values (1,repeat('a',3000)); | ||
insert into c values (2,repeat('a',3000)); | ||
insert into c values (3,repeat('a',3000)); | ||
insert into c values (4,repeat('a',3000)); | ||
insert into c values (5,repeat('a',3000)); | ||
|
||
insert into c values (-1,repeat('a',2000)); | ||
insert into c values (-2,repeat('a',2000)); | ||
insert into c values (-3,repeat('a',2000)); | ||
insert into c values (-4,repeat('a',2000)); | ||
insert into c values (-5,repeat('a',2000)); | ||
|
||
--connection con1 | ||
select id,length(val) from c order by id desc; | ||
set DEBUG="+d,desc_scan_debug"; | ||
set DEBUG_SYNC="desc_scan_before_restore_position SIGNAL desc_scan_before_restore_position_done WAIT_FOR continue"; | ||
send select id,length(val) from c order by id desc; | ||
--connection default | ||
set DEBUG_SYNC="now WAIT_FOR desc_scan_before_restore_position_done"; | ||
update c set val=repeat('b',6000) where id=2; | ||
set DEBUG_SYNC="now SIGNAL continue"; | ||
--connection con1 | ||
reap; | ||
set DEBUG="-d,desc_scan_debug"; | ||
--connection default | ||
drop table c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While PS-9092 blocked the merge(that caused records movement), this bug shows that records are moved without a merge.
But when a record is moved pessimistically, how can we assume it is transferred to a neighbour? You should limit this check if the movement is neighbour only.
If the record is moved to a non-neighbour, please check this case.
It should be protected by delete marking of record. ie we should read delete marked version of record and the new version that is moved to some far page is not visible/seen. This is OK.
To summarize:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but in our observations, pessimistic updates are limited to the current page and its sibling pages. Whether it is inserted after splitting or inserted directly into its sibling page, the inserted page needs to be disabled for optimistic access, so we do not need stricter judgment here. In addition, the original record has been physically deleted from the original page, and no changes to the delete-mark will be involved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's because for the query
update c set val=repeat('b',6000) where id=2,
the update only changes non-key fields, and the new record should always land on neighbour pages.But if there are queries that update key, records can move with delete marking.
For example UPDATE c SET id = 20 WHERE id = 5;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether it is PS-9092 or PS-9297, the necessary condition to trigger the problem is that the same physical record is moved between adjacent pages. But UPDATE c SET id = 20 WHERE id = 5; actually del-marks the record with id=5 and inserts the record with id=20 within a transaction. These two records are not physically the same record. Therefore I think this scenario is not affected by this problem, the ReadView of the read transaction will ensure that the correct version of the record is visible.