From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH v2 3/7] vinyl: prepare write iterator heap comparator for deferred DELETEs Date: Tue, 21 Aug 2018 14:15:36 +0300 [thread overview] Message-ID: <6ccfa9f9dfbf0c2deda8c45b89c90af0257ad3bf.1534847663.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1534847663.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1534847663.git.vdavydov.dev@gmail.com> In the scope of #2129, we won't delete the overwritten tuple from secondary indexes immediately on REPLACE. Instead we will defer generation of the DELETE statement until the primary index compaction. However, it may happen that the overwritten tuple and the tuple that overwrote it have the same secondary key parts, in which case the deferred DELETE is not needed and should be discarded on secondary index compaction. This patch makes the write iterator heap comparator function discard such useless deferred DELETEs. Note, this patch also removes the code that prioritises terminal statements over UPSERTs in the write iterator, which, according to the comment, may happen only during forced recovery. I don't see why we should do that, even during forced recovery, neither have I managed to find the reason in the commit history, so I dropped this code in order not to overburden the write iterator logic with some esoteric cases. Needed for #2129 --- src/box/vy_write_iterator.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/box/vy_write_iterator.c b/src/box/vy_write_iterator.c index 50c51f2b..de58012a 100644 --- a/src/box/vy_write_iterator.c +++ b/src/box/vy_write_iterator.c @@ -242,12 +242,15 @@ heap_less(heap_t *heap, struct heap_node *node1, struct heap_node *node2) if (lsn1 != lsn2) return lsn1 > lsn2; - /** - * LSNs are equal. This may happen only during forced recovery. - * Prioritize terminal (non-UPSERT) statements + /* + * LSNs are equal. This may only happen if one of the statements + * is a deferred DELETE and the overwritten tuple which it is + * supposed to purge has the same key parts as the REPLACE that + * overwrote it. Discard the deferred DELETE as the overwritten + * tuple will be (or has already been) purged by the REPLACE. */ - return (vy_stmt_type(src1->tuple) == IPROTO_UPSERT ? 1 : 0) < - (vy_stmt_type(src2->tuple) == IPROTO_UPSERT ? 1 : 0); + return (vy_stmt_type(src1->tuple) == IPROTO_DELETE ? 1 : 0) < + (vy_stmt_type(src2->tuple) == IPROTO_DELETE ? 1 : 0); } -- 2.11.0
next prev parent reply other threads:[~2018-08-21 11:15 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-21 11:15 [PATCH v2 0/7] vinyl: eliminate disk read on REPLACE/DELETE Vladimir Davydov 2018-08-21 11:15 ` [PATCH v2 1/7] vinyl: do not store meta in secondary index runs Vladimir Davydov 2018-08-21 15:08 ` Konstantin Osipov 2018-08-21 11:15 ` [PATCH v2 2/7] vinyl: teach write iterator to return overwritten tuples Vladimir Davydov 2018-08-21 15:14 ` Konstantin Osipov 2018-08-21 15:37 ` Vladimir Davydov 2018-08-21 11:15 ` Vladimir Davydov [this message] 2018-08-21 15:38 ` [PATCH v2 3/7] vinyl: prepare write iterator heap comparator for deferred DELETEs Konstantin Osipov 2018-08-21 11:15 ` [PATCH v2 4/7] vinyl: allow to skip certain statements on read Vladimir Davydov 2018-08-21 15:39 ` Konstantin Osipov 2018-08-21 11:15 ` [PATCH v2 5/7] Introduce _vinyl_deferred_delete system space Vladimir Davydov 2018-08-21 15:42 ` Konstantin Osipov 2018-08-22 17:04 ` Vladimir Davydov 2018-08-21 11:15 ` [PATCH v2 6/7] vinyl: zap vy_mem::min_lsn and rename max_lsn to dump_lsn Vladimir Davydov 2018-08-21 15:44 ` Konstantin Osipov 2018-08-22 13:00 ` Vladimir Davydov 2018-08-21 11:15 ` [PATCH v2 7/7] vinyl: eliminate disk read on REPLACE/DELETE Vladimir Davydov 2018-08-21 16:13 ` Konstantin Osipov 2018-08-22 17:08 ` Vladimir Davydov 2018-08-22 17:50 ` [PATCH v2 0/7] " 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=6ccfa9f9dfbf0c2deda8c45b89c90af0257ad3bf.1534847663.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v2 3/7] vinyl: prepare write iterator heap comparator for deferred DELETEs' \ /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