Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 10/12] vinyl: rename vy_log_record::commit_lsn to create_lsn
Date: Sun,  1 Apr 2018 12:05:37 +0300	[thread overview]
Message-ID: <610b8806c930064a1033ab156187057a26a9af57.1522572161.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1522572160.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1522572160.git.vdavydov.dev@gmail.com>

So as to draw the line between LSN of index creation and LSN of last
index modification, which is introduced by later in the series.
---
 src/box/vy_log.c | 40 ++++++++++++++++++++--------------------
 src/box/vy_log.h | 14 +++++++-------
 src/box/vy_lsm.c |  8 ++++----
 3 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/box/vy_log.c b/src/box/vy_log.c
index aeb31781..7fa395d5 100644
--- a/src/box/vy_log.c
+++ b/src/box/vy_log.c
@@ -80,7 +80,7 @@ enum vy_log_key {
 	VY_LOG_KEY_DUMP_LSN		= 9,
 	VY_LOG_KEY_GC_LSN		= 10,
 	VY_LOG_KEY_TRUNCATE_COUNT	= 11,
-	VY_LOG_KEY_COMMIT_LSN		= 12,
+	VY_LOG_KEY_CREATE_LSN		= 12,
 };
 
 /** vy_log_key -> human readable name. */
@@ -97,7 +97,7 @@ static const char *vy_log_key_name[] = {
 	[VY_LOG_KEY_DUMP_LSN]		= "dump_lsn",
 	[VY_LOG_KEY_GC_LSN]		= "gc_lsn",
 	[VY_LOG_KEY_TRUNCATE_COUNT]	= "truncate_count",
-	[VY_LOG_KEY_COMMIT_LSN]		= "commit_lsn",
+	[VY_LOG_KEY_CREATE_LSN]		= "create_lsn",
 };
 
 /** vy_log_type -> human readable name. */
@@ -247,10 +247,10 @@ vy_log_record_snprint(char *buf, int size, const struct vy_log_record *record)
 		SNPRINT(total, snprintf, buf, size, "%s=%"PRIi64", ",
 			vy_log_key_name[VY_LOG_KEY_SLICE_ID],
 			record->slice_id);
-	if (record->commit_lsn > 0)
+	if (record->create_lsn > 0)
 		SNPRINT(total, snprintf, buf, size, "%s=%"PRIi64", ",
-			vy_log_key_name[VY_LOG_KEY_COMMIT_LSN],
-			record->commit_lsn);
+			vy_log_key_name[VY_LOG_KEY_CREATE_LSN],
+			record->create_lsn);
 	if (record->dump_lsn > 0)
 		SNPRINT(total, snprintf, buf, size, "%s=%"PRIi64", ",
 			vy_log_key_name[VY_LOG_KEY_DUMP_LSN],
@@ -355,9 +355,9 @@ vy_log_record_encode(const struct vy_log_record *record,
 		size += mp_sizeof_uint(record->slice_id);
 		n_keys++;
 	}
-	if (record->commit_lsn > 0) {
-		size += mp_sizeof_uint(VY_LOG_KEY_COMMIT_LSN);
-		size += mp_sizeof_uint(record->commit_lsn);
+	if (record->create_lsn > 0) {
+		size += mp_sizeof_uint(VY_LOG_KEY_CREATE_LSN);
+		size += mp_sizeof_uint(record->create_lsn);
 		n_keys++;
 	}
 	if (record->dump_lsn > 0) {
@@ -428,9 +428,9 @@ vy_log_record_encode(const struct vy_log_record *record,
 		pos = mp_encode_uint(pos, VY_LOG_KEY_SLICE_ID);
 		pos = mp_encode_uint(pos, record->slice_id);
 	}
-	if (record->commit_lsn > 0) {
-		pos = mp_encode_uint(pos, VY_LOG_KEY_COMMIT_LSN);
-		pos = mp_encode_uint(pos, record->commit_lsn);
+	if (record->create_lsn > 0) {
+		pos = mp_encode_uint(pos, VY_LOG_KEY_CREATE_LSN);
+		pos = mp_encode_uint(pos, record->create_lsn);
 	}
 	if (record->dump_lsn > 0) {
 		pos = mp_encode_uint(pos, VY_LOG_KEY_DUMP_LSN);
@@ -549,8 +549,8 @@ vy_log_record_decode(struct vy_log_record *record,
 		case VY_LOG_KEY_SLICE_ID:
 			record->slice_id = mp_decode_uint(&pos);
 			break;
-		case VY_LOG_KEY_COMMIT_LSN:
-			record->commit_lsn = mp_decode_uint(&pos);
+		case VY_LOG_KEY_CREATE_LSN:
+			record->create_lsn = mp_decode_uint(&pos);
 			break;
 		case VY_LOG_KEY_DUMP_LSN:
 			record->dump_lsn = mp_decode_uint(&pos);
@@ -568,16 +568,16 @@ vy_log_record_decode(struct vy_log_record *record,
 			goto fail;
 		}
 	}
-	if (record->type == VY_LOG_CREATE_LSM && record->commit_lsn == 0) {
+	if (record->type == VY_LOG_CREATE_LSM && record->create_lsn == 0) {
 		/*
 		 * We used to use LSN as unique LSM tree identifier
 		 * and didn't store LSN separately so if there's
-		 * no 'commit_lsn' field in the record, we are
+		 * no 'create_lsn' field in the record, we are
 		 * recovering from an old vylog and 'id' is in
 		 * fact the LSN of the WAL record that committed
 		 * the LSM tree.
 		 */
-		record->commit_lsn = record->lsm_id;
+		record->create_lsn = record->lsm_id;
 	}
 	return 0;
 fail:
@@ -1171,7 +1171,7 @@ static int
 vy_recovery_create_lsm(struct vy_recovery *recovery, int64_t id,
 		       uint32_t space_id, uint32_t index_id,
 		       const struct key_part_def *key_parts,
-		       uint32_t key_part_count, int64_t commit_lsn)
+		       uint32_t key_part_count, int64_t create_lsn)
 {
 	struct vy_lsm_recovery_info *lsm;
 	struct key_part_def *key_parts_copy;
@@ -1257,7 +1257,7 @@ vy_recovery_create_lsm(struct vy_recovery *recovery, int64_t id,
 	lsm->key_parts = key_parts_copy;
 	lsm->key_part_count = key_part_count;
 	lsm->is_dropped = false;
-	lsm->commit_lsn = commit_lsn;
+	lsm->create_lsn = create_lsn;
 	lsm->dump_lsn = -1;
 
 	/*
@@ -1756,7 +1756,7 @@ vy_recovery_process_record(struct vy_recovery *recovery,
 		rc = vy_recovery_create_lsm(recovery, record->lsm_id,
 				record->space_id, record->index_id,
 				record->key_parts, record->key_part_count,
-				record->commit_lsn);
+				record->create_lsn);
 		break;
 	case VY_LOG_DROP_LSM:
 		rc = vy_recovery_drop_lsm(recovery, record->lsm_id);
@@ -2005,7 +2005,7 @@ vy_log_append_lsm(struct xlog *xlog, struct vy_lsm_recovery_info *lsm)
 	record.space_id = lsm->space_id;
 	record.key_parts = lsm->key_parts;
 	record.key_part_count = lsm->key_part_count;
-	record.commit_lsn = lsm->commit_lsn;
+	record.create_lsn = lsm->create_lsn;
 	if (vy_log_append_record(xlog, &record) != 0)
 		return -1;
 
diff --git a/src/box/vy_log.h b/src/box/vy_log.h
index 2dad4ee9..702963d5 100644
--- a/src/box/vy_log.h
+++ b/src/box/vy_log.h
@@ -66,7 +66,7 @@ enum vy_log_record_type {
 	/**
 	 * Create a new LSM tree.
 	 * Requires vy_log_record::lsm_id, index_id, space_id,
-	 * key_def (with primary key parts), commit_lsn.
+	 * key_def, create_lsn.
 	 */
 	VY_LOG_CREATE_LSM		= 0,
 	/**
@@ -200,8 +200,8 @@ struct vy_log_record {
 	struct key_part_def *key_parts;
 	/** Number of key parts. */
 	uint32_t key_part_count;
-	/** LSN of the WAL row corresponding to this record. */
-	int64_t commit_lsn;
+	/** LSN of the WAL row that created the LSM tree. */
+	int64_t create_lsn;
 	/** Max LSN stored on disk. */
 	int64_t dump_lsn;
 	/**
@@ -253,8 +253,8 @@ struct vy_lsm_recovery_info {
 	uint32_t key_part_count;
 	/** True if the LSM tree was dropped. */
 	bool is_dropped;
-	/** LSN of the WAL row that committed the LSM tree. */
-	int64_t commit_lsn;
+	/** LSN of the WAL row that created the LSM tree. */
+	int64_t create_lsn;
 	/** LSN of the last LSM tree dump. */
 	int64_t dump_lsn;
 	/**
@@ -503,7 +503,7 @@ vy_log_record_init(struct vy_log_record *record)
 /** Helper to log a vinyl LSM tree creation. */
 static inline void
 vy_log_create_lsm(int64_t id, uint32_t space_id, uint32_t index_id,
-		  const struct key_def *key_def, int64_t commit_lsn)
+		  const struct key_def *key_def, int64_t create_lsn)
 {
 	struct vy_log_record record;
 	vy_log_record_init(&record);
@@ -512,7 +512,7 @@ vy_log_create_lsm(int64_t id, uint32_t space_id, uint32_t index_id,
 	record.space_id = space_id;
 	record.index_id = index_id;
 	record.key_def = key_def;
-	record.commit_lsn = commit_lsn;
+	record.create_lsn = create_lsn;
 	vy_log_write(&record);
 }
 
diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c
index 915ffaeb..af6dde50 100644
--- a/src/box/vy_lsm.c
+++ b/src/box/vy_lsm.c
@@ -512,17 +512,17 @@ vy_lsm_recover(struct vy_lsm *lsm, struct vy_recovery *recovery,
 					    (unsigned)lsm->index_id));
 			return -1;
 		}
-		if (lsn > lsm_info->commit_lsn) {
+		if (lsn > lsm_info->create_lsn) {
 			/*
 			 * The last incarnation of the LSM tree was
 			 * created before the last checkpoint, load
 			 * it now.
 			 */
-			lsn = lsm_info->commit_lsn;
+			lsn = lsm_info->create_lsn;
 		}
 	}
 
-	if (lsm_info == NULL || lsn > lsm_info->commit_lsn) {
+	if (lsm_info == NULL || lsn > lsm_info->create_lsn) {
 		/*
 		 * If we failed to log LSM tree creation before restart,
 		 * we won't find it in the log on recovery. This is OK as
@@ -537,7 +537,7 @@ vy_lsm_recover(struct vy_lsm *lsm, struct vy_recovery *recovery,
 	lsm->id = lsm_info->id;
 	lsm->is_committed = true;
 
-	if (lsn < lsm_info->commit_lsn || lsm_info->is_dropped) {
+	if (lsn < lsm_info->create_lsn || lsm_info->is_dropped) {
 		/*
 		 * Loading a past incarnation of the LSM tree, i.e.
 		 * the LSM tree is going to dropped during final
-- 
2.11.0

  parent reply	other threads:[~2018-04-01  9:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-01  9:05 [PATCH 00/12] vinyl: allow to extend key def of non-empty index Vladimir Davydov
2018-04-01  9:05 ` [PATCH 01/12] index: add commit_modify virtual method Vladimir Davydov
2018-04-01  9:05 ` [PATCH 02/12] alter: require rebuild of all secondary vinyl indexes if pk changes Vladimir Davydov
2018-04-01  9:05 ` [PATCH 03/12] alter: do not rebuild secondary indexes on compatible " Vladimir Davydov
2018-04-05 12:30   ` Konstantin Osipov
2018-04-01  9:05 ` [PATCH 04/12] space: make space_swap_index method virtual Vladimir Davydov
2018-04-01  9:05 ` [PATCH 05/12] vinyl: do not reallocate tuple formats on alter Vladimir Davydov
2018-04-01 11:12   ` [tarantool-patches] " v.shpilevoy
2018-04-01 11:24     ` Vladimir Davydov
2018-04-01  9:05 ` [PATCH 06/12] vinyl: zap vy_lsm_validate_formats Vladimir Davydov
2018-04-01  9:05 ` [PATCH 07/12] vinyl: zap vy_mem_update_formats Vladimir Davydov
2018-04-01  9:05 ` [PATCH 08/12] vinyl: remove pointless is_nullable initialization for disk_format Vladimir Davydov
2018-04-01  9:05 ` [PATCH 09/12] vinyl: use source tuple format when copying field map Vladimir Davydov
2018-04-01  9:05 ` Vladimir Davydov [this message]
2018-04-01  9:05 ` [PATCH 11/12] vinyl: do not write VY_LOG_DUMP_LSM record to snapshot Vladimir Davydov
2018-04-01  9:05 ` [PATCH 12/12] vinyl: allow to modify key definition if it does not require rebuild Vladimir Davydov
2018-04-02  8:46   ` Vladimir Davydov
2018-04-05 14:32     ` Konstantin Osipov
2018-04-05 14:45     ` Konstantin Osipov
2018-04-05 14:48       ` Konstantin Osipov

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=610b8806c930064a1033ab156187057a26a9af57.1522572161.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 10/12] vinyl: rename vy_log_record::commit_lsn to create_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