[PATCH v2 3/7] vinyl: get rid of vy_env::join_lsn
Vladimir Davydov
vdavydov.dev at gmail.com
Mon Aug 19 19:53:16 MSK 2019
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
More information about the Tarantool-patches
mailing list