diff options
author | Chenhao Qu <chenhao.qu@mongodb.com> | 2021-01-25 10:17:02 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-25 11:01:39 +0000 |
commit | 62c3f69e2b2d2e805bb609edce01736f8ffa389b (patch) | |
tree | 314ef6ba4b2e51631d4d189207fca355eda49d27 /src/third_party/wiredtiger/src/log/log.c | |
parent | 4a262f6844b3a054f4d89c8d7dc802e263dbdfc1 (diff) | |
download | mongo-62c3f69e2b2d2e805bb609edce01736f8ffa389b.tar.gz |
Import wiredtiger: e39ffb554160de902060cd063c4b1547ff6d5e1e from branch mongodb-5.0
ref: 1e9c8aed12..e39ffb5541
for: 4.9.0
WT-6309 Add support for start/stop arguments to wt printlog command
WT-6866 Refactor python backup tests initial base class
WT-6946 Adding test tags to an initial set of test programs
WT-7084 Fix assert in test code and a comment error
WT-7109 Retain no longer supported configuration options for backward compatibility
WT-7113 Integrate prototype tiered storage code into WT
WT-7114 Revert Makefile code to always run the prototype script
Diffstat (limited to 'src/third_party/wiredtiger/src/log/log.c')
-rw-r--r-- | src/third_party/wiredtiger/src/log/log.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/third_party/wiredtiger/src/log/log.c b/src/third_party/wiredtiger/src/log/log.c index 46dce80113c..6ba60e60129 100644 --- a/src/third_party/wiredtiger/src/log/log.c +++ b/src/third_party/wiredtiger/src/log/log.c @@ -2042,7 +2042,7 @@ __log_salvage_message( * Scan the logs, calling a function on each record found. */ int -__wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, +__wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *start_lsnp, WT_LSN *end_lsnp, uint32_t flags, int (*func)(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, WT_LSN *next_lsnp, void *cookie, int firstrecord), void *cookie) @@ -2080,7 +2080,7 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, if (func == NULL) return (0); - if (lsnp != NULL && LF_ISSET(WT_LOGSCAN_FIRST | WT_LOGSCAN_FROM_CKP)) + if (start_lsnp != NULL && LF_ISSET(WT_LOGSCAN_FIRST | WT_LOGSCAN_FROM_CKP)) WT_RET_MSG(session, WT_ERROR, "choose either a start LSN or a start flag"); /* * Set up the allocation size, starting and ending LSNs. The values for those depend on whether @@ -2091,7 +2091,7 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, allocsize = log->allocsize; WT_ASSIGN_LSN(&end_lsn, &log->alloc_lsn); WT_ASSIGN_LSN(&start_lsn, &log->first_lsn); - if (lsnp == NULL) { + if (start_lsnp == NULL) { if (LF_ISSET(WT_LOGSCAN_FROM_CKP)) WT_ASSIGN_LSN(&start_lsn, &log->ckpt_lsn); else if (!LF_ISSET(WT_LOGSCAN_FIRST)) @@ -2121,16 +2121,17 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, WT_SET_LSN(&end_lsn, lastlog, 0); WT_ERR(__wt_fs_directory_list_free(session, &logfiles, logcount)); } - if (lsnp != NULL) { + + if (start_lsnp != NULL) { /* * Offsets must be on allocation boundaries. An invalid LSN from a user should just return * WT_NOTFOUND. It is not an error. But if it is from recovery, we expect valid LSNs so give * more information about that. */ - if (lsnp->l.offset % allocsize != 0) { + if (start_lsnp->l.offset % allocsize != 0) { if (LF_ISSET(WT_LOGSCAN_RECOVER | WT_LOGSCAN_RECOVER_METADATA)) WT_ERR_MSG(session, WT_NOTFOUND, "__wt_log_scan unaligned LSN %" PRIu32 "/%" PRIu32, - lsnp->l.file, lsnp->l.offset); + start_lsnp->l.file, start_lsnp->l.offset); else WT_ERR(WT_NOTFOUND); } @@ -2139,11 +2140,11 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, * return WT_NOTFOUND. It is not an error. But if it is from recovery, we expect valid LSNs * so give more information about that. */ - if (lsnp->l.file > lastlog) { + if (start_lsnp->l.file > lastlog) { if (LF_ISSET(WT_LOGSCAN_RECOVER | WT_LOGSCAN_RECOVER_METADATA)) WT_ERR_MSG(session, WT_NOTFOUND, "__wt_log_scan LSN %" PRIu32 "/%" PRIu32 " larger than biggest log file %" PRIu32, - lsnp->l.file, lsnp->l.offset, lastlog); + start_lsnp->l.file, start_lsnp->l.offset, lastlog); else WT_ERR(WT_NOTFOUND); } @@ -2151,8 +2152,8 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, * Log cursors may not know the starting LSN. If an LSN is passed in that it is equal to the * smallest LSN, start from the beginning of the log. */ - if (!WT_IS_INIT_LSN(lsnp)) - WT_ASSIGN_LSN(&start_lsn, lsnp); + if (!WT_IS_INIT_LSN(start_lsnp)) + WT_ASSIGN_LSN(&start_lsn, start_lsnp); } WT_ERR(__log_open_verify(session, start_lsn.l.file, &log_fh, &prev_lsn, NULL, &need_salvage)); if (need_salvage) @@ -2387,6 +2388,13 @@ advance: if (LF_ISSET(WT_LOGSCAN_ONE)) break; } + + /* + * Exit the scanning loop if the next LSN seen is greater than our user set end range LSN. + */ + if (end_lsnp != NULL && __wt_log_cmp(&next_lsn, end_lsnp) > 0) + break; + WT_ASSIGN_LSN(&rd_lsn, &next_lsn); } @@ -2687,7 +2695,7 @@ __log_write_internal(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, ui __wt_log_slot_free(session, myslot.slot); } else if (force) { /* - * If we are going to wait for this slot to get written, signal the wrlsn thread. + * If we are going to wait for this slot to get written, signal the log server thread. * * XXX I've seen times when conditions are NULL. */ |