Skip to content

Commit

Permalink
vinyl: rotate mem during index build on demand
Browse files Browse the repository at this point in the history
Meanwhile in 17f6af7 the similar problem has been fixed, still it may
appear that in-memory level of secondary index being constructed has
lagging memory generation (in other words, it's values is less than
the value of current global generation). Such situation can be achieved
if yield which is required to check uniqueness of value being inserted
is too long. In this time gap other space may trigger dump process
bumping global memory generation counter, but dump itself is still not
yet scheduled.

So to get rid of generations mismatch, let's rotate in-memory level
after yield on demand.

Note that test is not included into the patch due to its complexity
and will be added as a follow-up.

Closes #5042

(cherry picked from commit c3561b1)
  • Loading branch information
Korablev77 committed Jun 10, 2020
1 parent eb7e1b6 commit f3d0b6f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/box/vinyl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4097,6 +4097,12 @@ vy_build_insert_tuple(struct vy_env *env, struct vy_lsm *lsm,
* Hence, to get right mem (during mem rotation it becomes
* sealed i.e. read-only) we should fetch it from lsm again.
*/
if (lsm->mem->generation != *lsm->env->p_generation) {
if (vy_lsm_rotate_mem(lsm) != 0) {
tuple_unref(stmt);
return -1;
}
}
mem = lsm->mem;

/* Insert the new tuple into the in-memory index. */
Expand Down

0 comments on commit f3d0b6f

Please sign in to comment.