Skip to content
Snippets Groups Projects
Commit d21971cd authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy Committed by Roman Tsisyk
Browse files

vinyl: fix mem restore in case of not started mem iterator

If vy_mem_iterator was not started, the vy_mem_iterator_restore had been
able to iterate to the same key, as the target of restore, and then call
vy_mem_iterator_next_lsn_impl to find the older lsn.

But the vy_mem_iterator_start_from did not set 'search_started' flag and
next_lsn_impl would restart the mem iterator again, to the first statement,
which could be incorrect result of restore.

Example:

cache statements: {1}, {2}, {3}
mem statements: {1}, {2}, {3}
iterator: GE
key: {1}

- merge_iterator returns all cached data and then tries to restore mem on {3}.
- then mem_iterator during restore calls vy_mem_iterator_start_from and sees tuple {3}.
- then mem_iterator tries to find older lsn and calls vy_mem_iterator_next_lsn_impl,
  which sees 'search_started = false' and restarts iterator to {1}.
- then read_iterator returns {1} after {3} - ERROR!

Lets set 'search_started' flag inside vy_mem_iterator_start_from.
parent a03a4a99
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment