From: Nikita Pettik <korablev@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH] vinyl: fix assert in vy_tx_write()
Date: Fri, 22 May 2020 03:04:43 +0000 [thread overview]
Message-ID: <20200522030443.GB24698@tarantool.org> (raw)
In-Reply-To: <7e71d3cd-1c50-c236-d222-95f13b24da5a@tarantool.org>
On 21 May 16:12, Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
>
> On 21/05/2020 03:15, Nikita Pettik wrote:
> > Assert in vy_tx_write() validates that upsert applied on the top of
> > cached statement is always replace. In fact, it is not always so. If
> > vy_apply_upsert() fails due to the fact that PK is modified, it returns
> > old statement (i.e. statement which upsert is applied on). In this
> > regard, if tuple cache contains insert and invalid upsert is executed,
> > vy_apply_upsert() will return insert. As a result, assert will fire.
> > Let's fix it and take into account that vy_apply_upsert() is able to
> > return inserts as well.
>
> I looked at other places in vinyl, which apply an upsert, and found
> vy_lsm_commit_upsert() in vy_lsm.c:1018. The result is also always
> assumed to be REPLACE. Is it correct?
No, it's not a case. If vy_apply_upsert() fails due to PK modification,
it will return old_stmt. In turn old_stmt has different LSN, so flaw
returns before this assert:
1030 if (upserted_lsn != lsn) {
1031 /**
1032 * This could only happen if the upsert completely
1033 * failed and the old tuple was returned.
1034 * In this case we shouldn't insert the same replace
1035 * again.
1036 */
1037 assert(older.stmt == NULL ||
1038 upserted_lsn == vy_stmt_lsn(older.stmt));
1039 tuple_unref(upserted.stmt);
1040 return;
1041 }
Note that they must have different LSN since they can't come in one
tx set. Otherwise, during apply_upsert() in vy_tx_set_entry() upsert
turns into old_stmt (insert) and simply skipped (due to is_overwritten
flag) during statement commit.
next prev parent reply other threads:[~2020-05-22 3:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-21 1:15 Nikita Pettik
2020-05-21 14:12 ` Vladislav Shpilevoy
2020-05-22 3:04 ` Nikita Pettik [this message]
2020-05-26 21:44 ` Vladislav Shpilevoy
2020-05-27 12:51 ` Nikita Pettik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200522030443.GB24698@tarantool.org \
--to=korablev@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH] vinyl: fix assert in vy_tx_write()' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox