[Tarantool-patches] [PATCH 2/2] vinyl: skip invalid upserts during squash
Nikita Pettik
korablev at tarantool.org
Thu May 14 05:11:55 MSK 2020
On 14 Apr 01:12, Konstantin Osipov wrote:
> * Nikita Pettik <korablev at tarantool.org> [20/04/14 00:57]:
> > Instead of aborting merge sequence of upserts let's log appeared
> > errors and skip upserts which can't be applied. It makes sense
> > taking into consideration previous commit: now upsert statements which
> > can't be applied may appear in mems/runs (previously squash operation
> > might fail only due to OOM). As a result, if we didn't ignore invalid
> > upserts, dump or compaction processes would not be able to finish (owing
> > to inability to squash upserts).
>
> We should log the upsert itself, base64 encoded.
It is logged with following format (in vy_read_view_merge()):
say_info("upsert %s is not applied due to the error: %s",
vy_stmt_str(h->tuple), e->errmsg);
It is the function which is called during compaction to squash
upserts.
Also, I've added logs during squash/apply of upserts in in-memory
tree: see diffs in vy_tx_write() and vy_tx_set(). So that user gets
the same error as when executing invalid upserts in memtx. However,
I've found these logs a bit inconsistent: upserts are not always
squashed/applied once they are inserted in tree. For instance:
s = box.schema.space.create('test', { engine = 'vinyl', field_count = 2 })
pk = s:create_index('pk')
s:replace{1, 1}
s:upsert({1, 1}, {{'=', 3, 5}})
main/101/interactive tuple.c:150 E> ER_EXACT_FIELD_COUNT: Tuple field count 3 does not match space field count 2
This upsert is attepted to be optimized: in vy_lsm_commit_upsert()
we try to apply it on replace statement, but we fail so error is logged
(still upsert has been inserted in tree). Now, if we execute this
upsert once again:
s:upsert({1, 1}, {{'=', 3, 5}})
error won't be logged, since previous upsert now resides in tree
and we won't attempt at applying it (according to optimization's conditions).
Hence now I'm not sure that logging failed upsert squashes/applications
is worth it when it comes for in-memory lsm level.
> Second, vy_history_apply may be called from many contexts - reads
> and writes, for example. We should only log and skip during
> compaction, not when reading, otherwise we'll spam the log file at
> least.
We don't log anything in vy_history_apply(). So there are no logs
during reads.
> Finally, let's double check there are no issues with the used
> format - can it become obsolete by the time it's used, e.g. if
> there is an online/non-blocking schema change that happened in tx
> thread (compaction is running in the write thread)?
Upserts are supported only by primary index. Meanwhile vinyl does
not support altering primary index of non-empty space. Am I missing
something?
More information about the Tarantool-patches
mailing list