From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp34.i.mail.ru (smtp34.i.mail.ru [94.100.177.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 198AD469710 for ; Thu, 14 May 2020 05:11:57 +0300 (MSK) Date: Thu, 14 May 2020 02:11:55 +0000 From: Nikita Pettik Message-ID: <20200514021155.GB18509@tarantool.org> References: <670c3876e58a7cfa14d45db1dc074a10dd034759.1586808463.git.korablev@tarantool.org> <20200413221229.GA3462@atlas> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200413221229.GA3462@atlas> Subject: Re: [Tarantool-patches] [PATCH 2/2] vinyl: skip invalid upserts during squash List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Konstantin Osipov , tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org On 14 Apr 01:12, Konstantin Osipov wrote: > * Nikita Pettik [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?