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

Phantom read after gets from different indexes #7828

Closed
CuriousGeorgiy opened this issue Oct 20, 2022 · 1 comment · Fixed by #7836
Closed

Phantom read after gets from different indexes #7828

CuriousGeorgiy opened this issue Oct 20, 2022 · 1 comment · Fixed by #7836
Assignees
Labels
bug Something isn't working memtx mvcc

Comments

@CuriousGeorgiy
Copy link
Member

CuriousGeorgiy commented Oct 20, 2022

Steps to reproduce

os.execute('rm -rf *.snap *.xlog *.vylog 512')

local json = require('json')
local log = require('log')
local txn_proxy = require('txn_proxy')

box.cfg{memtx_use_mvcc_engine = true}

box.schema.space.create('s')
box.space.s:create_index('pk')
box.space.s:create_index('sk', {parts = {{2}}})

local tx1 = txn_proxy:new()
local tx2 = txn_proxy:new()
local tx3 = txn_proxy:new()

tx1('box.begin()')
tx2('box.begin()')
tx3('box.begin()')

tx1('box.space.s:replace{0, 1}')

tx2('box.space.s.index[1]:get{1}')
tx2('box.space.s:get{0}')

tx3('box.space.s:insert{1, 1}')

tx1('box.rollback()')

box.space.s:insert{0, 2}

log.info(json.encode(tx2('box.space.s:select({}, {fullscan = true})')))

os.exit()

Actual behavior

2022-10-20 11:50:57.427 [3180] main/103/repro.lua I> ""
2022-10-20 11:50:57.427 [3180] main/103/repro.lua I> [[]]
2022-10-20 11:50:57.427 [3180] main/103/repro.lua I> [[[0,0]]]

Expected behavior

2022-10-20 11:50:57.427 [3180] main/103/repro.lua I> ""
2022-10-20 11:50:57.427 [3180] main/103/repro.lua I> [[]]
2022-10-20 11:50:57.427 [3180] main/103/repro.lua I> [[]]
@CuriousGeorgiy CuriousGeorgiy added bug Something isn't working memtx mvcc labels Oct 20, 2022
@CuriousGeorgiy CuriousGeorgiy changed the title Phantom reads from secondary index after get and select Phantom read from secondary index after get and select Oct 23, 2022
@CuriousGeorgiy CuriousGeorgiy self-assigned this Oct 23, 2022
CuriousGeorgiy added a commit to CuriousGeorgiy/tarantool that referenced this issue Oct 23, 2022
During rollback read trackers are rebound to newer or older story, if
present: the index mask passed to `memtx_tx_track_read_story_slow`
is equal to the current index from which the story is unlinked and it
overwrites the tracker's index mask — pass the tracker's index mask
instead.

Closes tarantool#7828

NO_DOC=bugfix
@CuriousGeorgiy CuriousGeorgiy changed the title Phantom read from secondary index after get and select Phantom read after gets from different indexes Oct 23, 2022
CuriousGeorgiy added a commit to CuriousGeorgiy/tarantool that referenced this issue Oct 23, 2022
During rollback read trackers are rebound to newer or older story, if
present: the index mask passed to `memtx_tx_track_read_story_slow`
is equal to the current index from which the story is unlinked and it
overwrites the tracker's index mask — pass the tracker's index mask
instead.

Closes tarantool#7828

NO_DOC=bugfix
@CuriousGeorgiy
Copy link
Member Author

Another case from #7837:

os.execute('rm -rf *.snap *.xlog *.vylog 512')

local json = require('json')
local log = require('log')
local txn_proxy = require('txn_proxy')

box.cfg{memtx_use_mvcc_engine = true}

box.schema.space.create('s')
box.space.s:create_index('pk')
box.space.s:create_index('sk', {parts = {{2}}})

local tx1 = txn_proxy:new()
local tx2 = txn_proxy:new()
local tx3 = txn_proxy:new()

tx1('box.begin()')
tx2('box.begin()')
tx3('box.begin()')

tx1('box.space.s:replace{0, 1}')

tx2('box.space.s.index[1]:get{1}')
tx2('box.space.s:get{0}')

tx3('box.space.s:insert{1, 1}')

tx1('box.rollback()')

box.space.s:insert{0, 2}

log.info(json.encode(tx2('box.space.s:select({}, {fullscan = true})')))

os.exit()

CuriousGeorgiy added a commit to CuriousGeorgiy/tarantool that referenced this issue Oct 28, 2022
During rollback read trackers are rebound to newer or older story, if
present. The problem with the current logic is that read trackers are
basically rebound in the first available index: all information about key
parts read from other indexes gets lost — rebind read trackers in all
indexes.

Closes tarantool#7828

NO_DOC=bugfix
CuriousGeorgiy added a commit to CuriousGeorgiy/tarantool that referenced this issue Oct 28, 2022
During rollback read trackers are rebound to newer or older story, if
present. The problem with the current logic is that read trackers are
basically rebound in the first available index: all information about key
parts read from other indexes gets lost — rebind read trackers in all
indexes.

Closes tarantool#7828

NO_DOC=bugfix
CuriousGeorgiy added a commit to CuriousGeorgiy/tarantool that referenced this issue Nov 9, 2022
During rollback read trackers are rebound to newer or older story, if
present. The problem with the current logic is that read trackers are
basically rebound in the first available index: all information about key
parts read from other indexes gets lost — rebind read trackers in all
indexes.

Closes tarantool#7828

NO_DOC=bugfix
alyapunov pushed a commit that referenced this issue Nov 30, 2022
During rollback read trackers are rebound to newer or older story, if
present. The problem with the current logic is that read trackers are
basically rebound in the first available index: all information about key
parts read from other indexes gets lost — rebind read trackers in all
indexes.

Closes #7828

NO_DOC=bugfix
alyapunov pushed a commit that referenced this issue Nov 30, 2022
During rollback read trackers are rebound to newer or older story, if
present. The problem with the current logic is that read trackers are
basically rebound in the first available index: all information about key
parts read from other indexes gets lost — rebind read trackers in all
indexes.

Closes #7828

NO_DOC=bugfix

(cherry picked from commit 559b27d)
CuriousGeorgiy added a commit to CuriousGeorgiy/tarantool that referenced this issue Jun 16, 2023
During rollback read trackers are rebound to newer or older story, if
present: the index mask passed to `memtx_tx_track_read_story_slow`
is equal to the current index from which the story is unlinked and it
overwrites the tracker's index mask — pass the tracker's index mask
instead.

Closes tarantool#7828

NO_DOC=bugfix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working memtx mvcc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant