From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 10/12] vinyl: rename vy_log_record::commit_lsn to create_lsn Date: Sun, 1 Apr 2018 12:05:37 +0300 Message-Id: <610b8806c930064a1033ab156187057a26a9af57.1522572161.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: 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