diff --git a/client/tarantar/indexate.c b/client/tarantar/indexate.c index 10416048232ef92acb29af5cfc0b8d2ac19e5150..f423895be30e590bda50cf6c76b6c1b3381d569b 100644 --- a/client/tarantar/indexate.c +++ b/client/tarantar/indexate.c @@ -322,6 +322,10 @@ xlog_process(struct ts_spaces *s, char *wal_dir, uint64_t file_lsn, *last = xs->log.current.hdr.lsn; if (xs->log.current.hdr.lsn <= start) continue; + if (tss.opts.to_lsn_set && xs->log.current.hdr.lsn > tss.opts.to_lsn) { + rc = 1; + goto done; + } rc = xlog_process_row(s, fileid, xs->log.current_offset, r); if (rc == -1) goto done; @@ -352,8 +356,8 @@ waldir_processof(struct ts_spaces *s, struct tnt_dir *wal_dir, int i) if (i < wal_dir->count) { rc = xlog_process(s, wal_dir->path, wal_dir->files[i].lsn, tss.last_snap_lsn, &tss.last_xlog_lsn); - if (rc == -1) - return -1; + if (rc == -1 || rc == -1) + return rc; } for (i++; i < wal_dir->count; i++) { rc = xlog_process(s, wal_dir->path, wal_dir->files[i].lsn, @@ -361,7 +365,7 @@ waldir_processof(struct ts_spaces *s, struct tnt_dir *wal_dir, int i) if (rc == -1) return -1; } - return 0; + return rc; } static int diff --git a/client/tarantar/options.c b/client/tarantar/options.c index 13fc74c65eb14034d97eaf8334526cb3021e232f..b61c729c907f8bdf951278188cf834a697cf221f 100644 --- a/client/tarantar/options.c +++ b/client/tarantar/options.c @@ -44,6 +44,8 @@ static const void *opts_def = gopt_start( gopt_option('c', 0, gopt_shorts('c'), gopt_longs("create"), NULL, "create snapshot file"), + gopt_option('l', GOPT_ARG, gopt_shorts('l'), + gopt_longs("lsn"), " <u64>", "snapshot lsn (latest by default)"), gopt_option('?', 0, gopt_shorts(0), gopt_longs("help"), NULL, "display this help and exit"), gopt_option('v', 0, gopt_shorts('v'), gopt_longs("version"), @@ -81,6 +83,13 @@ ts_options_process(struct ts_options *opts, int argc, char **argv) opts->mode = TS_MODE_VERSION; goto done; } + + /* lsn */ + const char *arg = NULL; + if (gopt_arg(opt, 'l', &arg)) { + opts->to_lsn = atoll(arg); + opts->to_lsn_set = 1; + } /* generate or verify */ if (gopt(opt, 'c')) { opts->mode = TS_MODE_CREATE; diff --git a/client/tarantar/options.h b/client/tarantar/options.h index edeb7ab276189d7cb6df9ab38ccdc341148474d8..d571aaa7a6daa4f329c3a7e0b411c564e1645c65 100644 --- a/client/tarantar/options.h +++ b/client/tarantar/options.h @@ -9,6 +9,8 @@ enum ts_options_mode { struct ts_options { enum ts_options_mode mode; + int to_lsn_set; + uint64_t to_lsn; const char *file_config; struct tarantool_cfg cfg; }; diff --git a/client/tarantar/ts.h b/client/tarantar/ts.h index 0f1ffb61826a81f54dd5600efb1d3ebe4bc92c5a..a385dbc1d4acda0a5265f608f884fc4c4ff6ec15 100644 --- a/client/tarantar/ts.h +++ b/client/tarantar/ts.h @@ -7,7 +7,8 @@ struct ts { struct ts_reftable rt; uint64_t last_snap_lsn; uint64_t last_xlog_lsn; - + int to_lsn_set; + uint64_t to_lsn; struct slab_cache sc; struct region ra; };