From: Vladimir Davydov <vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org Subject: [PATCH v2 3/7] vinyl: get rid of vy_env::join_lsn Date: Mon, 19 Aug 2019 19:53:16 +0300 [thread overview] Message-ID: <bc28d9036264f7b41dc8a537ffe7f53a2ae2eb70.1566233187.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1566233187.git.vdavydov.dev@gmail.com> This fake LSN counter, which is used for assigning LSNs to Vinyl statements during the initial join stage, was introduced a long time ago, when LSNs were used as identifiers for lsregion allocations and hence were supposed to grow strictly monotonically with each new transaction. Later on, they were reused for assigning unique LSNs to identify indexes in vylog. These days, we don't need initial join LSNs to be unique, as we switched to generations for lsregion allocations while in vylog we now use LSNs only as an incarnation counter, not as a unique identifier. That said, let's zap vy_env::join_lsn and simply assign 0 to all statements received during the initial join stage. To achieve that, we just need to relax an assertion in vy_tx_commit() and remove the assumption that an LSN can't be zero in the write iterator implementation. --- src/box/vinyl.c | 24 ++---------------------- src/box/vy_tx.c | 2 +- src/box/vy_write_iterator.c | 8 ++++---- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 9e93153b..80ed00a1 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -123,17 +123,6 @@ struct vy_env { struct vy_recovery *recovery; /** Local recovery vclock. */ const struct vclock *recovery_vclock; - /** - * LSN to assign to the next statement received during - * initial join. - * - * We can't use original statements' LSNs, because we - * send statements not in the chronological order while - * the receiving end expects LSNs to grow monotonically - * due to the design of the lsregion allocator, which is - * used for storing statements in memory. - */ - int64_t join_lsn; /** Path to the data directory. */ char *path; /** Max time a transaction may wait for memory. */ @@ -792,15 +781,6 @@ vinyl_index_commit_create(struct index *index, int64_t lsn) return; } - if (env->status == VINYL_INITIAL_RECOVERY_REMOTE) { - /* - * Records received during initial join do not - * have LSNs so we use a fake one to identify - * the index in vylog. - */ - lsn = ++env->join_lsn; - } - /* * Backward compatibility fixup: historically, we used * box.info.signature for LSN of index creation, which @@ -3023,7 +3003,7 @@ vy_send_range_f(struct cbus_call_msg *cmsg) break; /* * Reset the LSN as the replica will ignore it - * anyway - see comment to vy_env::join_lsn. + * anyway. */ xrow.lsn = 0; rc = xstream_write(ctx->stream, &xrow); @@ -3269,7 +3249,7 @@ vinyl_space_apply_initial_join_row(struct space *space, struct request *request) rc = vy_tx_prepare(tx); if (rc == 0) - vy_tx_commit(tx, ++env->join_lsn); + vy_tx_commit(tx, 0); else vy_tx_rollback(tx); diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c index 9b300fde..1a5d4837 100644 --- a/src/box/vy_tx.c +++ b/src/box/vy_tx.c @@ -804,7 +804,7 @@ vy_tx_commit(struct vy_tx *tx, int64_t lsn) if (vy_tx_is_ro(tx)) goto out; - assert(xm->lsn < lsn); + assert(xm->lsn <= lsn); xm->lsn = lsn; /* Fix LSNs of the records and commit changes. */ diff --git a/src/box/vy_write_iterator.c b/src/box/vy_write_iterator.c index e7bb6f06..e5ed4e42 100644 --- a/src/box/vy_write_iterator.c +++ b/src/box/vy_write_iterator.c @@ -511,7 +511,7 @@ vy_write_iterator_merge_step(struct vy_write_iterator *stream) * Try to get VLSN of the read view with the specified number in * the vy_write_iterator.read_views array. * If the requested read view is older than all existing ones, - * return 0, as the oldest possible VLSN. + * return -1, which is less than any possible VLSN. * * @param stream Write iterator. * @param current_rv_i Index of the read view. @@ -522,7 +522,7 @@ static inline int64_t vy_write_iterator_get_vlsn(struct vy_write_iterator *stream, int rv_i) { if (rv_i >= stream->rv_count) - return 0; + return -1; return stream->read_views[rv_i].vlsn; } @@ -753,8 +753,8 @@ vy_write_iterator_build_history(struct vy_write_iterator *stream, * and other optimizations. */ if (vy_stmt_type(src->entry.stmt) == IPROTO_DELETE && - stream->is_last_level && merge_until_lsn == 0) { - current_rv_lsn = 0; /* Force skip */ + stream->is_last_level && merge_until_lsn < 0) { + current_rv_lsn = -1; /* Force skip */ goto next_lsn; } -- 2.20.1
next prev parent reply other threads:[~2019-08-19 16:53 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-19 16:53 [PATCH v2 0/7] Join replicas off the current read view Vladimir Davydov 2019-08-19 16:53 ` [PATCH v2 1/7] vinyl: don't pin index for iterator lifetime Vladimir Davydov 2019-08-19 20:35 ` [tarantool-patches] " Konstantin Osipov 2019-08-19 16:53 ` [PATCH v2 2/7] vinyl: don't exempt dropped indexes from dump and compaction Vladimir Davydov 2019-08-19 20:47 ` [tarantool-patches] " Konstantin Osipov 2019-08-20 8:12 ` Vladimir Davydov 2019-08-20 9:02 ` Vladimir Davydov 2019-08-20 11:52 ` Konstantin Osipov 2019-08-20 14:16 ` Vladimir Davydov 2019-08-19 16:53 ` Vladimir Davydov [this message] 2019-08-19 20:49 ` [tarantool-patches] Re: [PATCH v2 3/7] vinyl: get rid of vy_env::join_lsn Konstantin Osipov 2019-08-19 16:53 ` [PATCH v2 4/7] memtx: use ref counting to pin indexes for snapshot Vladimir Davydov 2019-08-19 20:50 ` [tarantool-patches] " Konstantin Osipov 2019-08-19 16:53 ` [PATCH v2 5/7] memtx: enter small delayed free mode from snapshot iterator Vladimir Davydov 2019-08-19 20:51 ` [tarantool-patches] " Konstantin Osipov 2019-08-19 16:53 ` [PATCH v2 6/7] space: get rid of apply_initial_join_row method Vladimir Davydov 2019-08-19 20:54 ` [tarantool-patches] " Konstantin Osipov 2019-08-19 16:53 ` [PATCH v2 7/7] relay: join new replicas off read view Vladimir Davydov 2019-08-19 20:57 ` [tarantool-patches] " Konstantin Osipov 2019-08-20 8:16 ` Vladimir Davydov 2019-08-20 11:53 ` Konstantin Osipov 2019-08-20 12:05 ` Vladimir Davydov 2019-08-20 13:50 ` Konstantin Osipov 2019-08-20 14:03 ` Vladimir Davydov 2019-08-21 22:08 ` Konstantin Osipov 2019-08-22 8:05 ` Vladimir Davydov 2019-08-19 16:54 ` [PATCH v2 0/7] Join replicas off the current " Vladimir Davydov 2019-08-20 8:53 ` 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=bc28d9036264f7b41dc8a537ffe7f53a2ae2eb70.1566233187.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v2 3/7] vinyl: get rid of vy_env::join_lsn' \ /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