From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 3/4] vinyl: do not panic if secondary index is inconsistent with primary Date: Tue, 15 May 2018 17:08:39 +0300 [thread overview] Message-ID: <b66cf42b0177263a4366ef8454745d9b5968ab5d.1526392563.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1526392563.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1526392563.git.vdavydov.dev@gmail.com> Although the bug in vy_task_dump_complete() due to which a tuple could be lost during dump was fixed, there still may be affected deployments as the bug was persisted on disk. To avoid occasional crashes on such deployments, let's make vinyl_iterator_secondary_next() skip tuples that are present in a secondary index but missing in the primary. Closes #3393 --- src/box/vinyl.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index ff4c2831..05aab30b 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -3844,6 +3844,7 @@ vinyl_iterator_secondary_next(struct iterator *base, struct tuple **ret) assert(it->lsm->index_id > 0); struct tuple *tuple; +next: if (it->tx == NULL) { diag_set(ClientError, ER_CURSOR_NO_TRANSACTION); goto fail; @@ -3853,7 +3854,6 @@ vinyl_iterator_secondary_next(struct iterator *base, struct tuple **ret) goto fail; } - if (vy_read_iterator_next(&it->iterator, &tuple) != 0) goto fail; @@ -3876,11 +3876,26 @@ vinyl_iterator_secondary_next(struct iterator *base, struct tuple **ret) * Note, there's no need in vy_tx_track() as the * tuple is already tracked in the secondary index. */ + struct tuple *full_tuple; if (vy_point_lookup(it->lsm->pk, it->tx, vy_tx_read_view(it->tx), - tuple, &tuple) != 0) + tuple, &full_tuple) != 0) goto fail; - *ret = tuple_bless(tuple); - tuple_unref(tuple); + if (full_tuple == NULL) { + /* + * All indexes of a space must be consistent, i.e. + * if a tuple is present in one index, it must be + * present in all other indexes as well, so we can + * get here only if there's a bug somewhere in vinyl. + * Don't abort as core dump won't really help us in + * this case. Just warn the user and proceed to the + * next tuple. + */ + say_warn("%s: key %s missing in primary index", + vy_lsm_name(it->lsm), vy_stmt_str(tuple)); + goto next; + } + *ret = tuple_bless(full_tuple); + tuple_unref(full_tuple); if (*ret != NULL) return 0; fail: -- 2.11.0
next prev parent reply other threads:[~2018-05-15 14:08 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-15 14:08 [PATCH 0/4] vinyl: fix crash in vinyl_iterator_secondary_next() Vladimir Davydov 2018-05-15 14:08 ` [PATCH 1/4] vinyl: fix EQ check in run iterator Vladimir Davydov 2018-05-15 19:05 ` Konstantin Osipov 2018-05-15 19:23 ` Vladimir Davydov 2018-05-15 14:08 ` [PATCH 2/4] vinyl: fix lost key on dump completion Vladimir Davydov 2018-05-15 19:20 ` Konstantin Osipov 2018-05-15 19:27 ` Vladimir Davydov 2018-05-15 14:08 ` Vladimir Davydov [this message] 2018-05-15 14:08 ` [PATCH 4/4] test: improve vinyl/select_consistency Vladimir Davydov
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=b66cf42b0177263a4366ef8454745d9b5968ab5d.1526392563.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 3/4] vinyl: do not panic if secondary index is inconsistent with primary' \ /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