diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-08-01 16:42:49 +1000 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-08-01 16:42:49 +1000 |
commit | 835bfb21d8e67663d84a40aa4f7370a4403725a9 (patch) | |
tree | 4f5edb231524f95272f834e31461ba4e17e52903 /src/third_party/wiredtiger/src/txn/txn_log.c | |
parent | 6300b3bd4ad9cd238a02bdb8ca681a447913f1af (diff) | |
download | mongo-835bfb21d8e67663d84a40aa4f7370a4403725a9.tar.gz |
Import wiredtiger: 2e9744d11a65c63ba7445060dc78371250f04051 from branch mongodb-3.6
ref: 6173a98979..2e9744d11a
for: 3.5.11
WT-2309 Add yields and/or sleeps in #DIAGNOSTIC mode
WT-3047 Add mode aimed at uncovering race conditions in split code
WT-3308 Add statistics tracking around yield loops
WT-3316 Add new engineering section to reference guide documentation
WT-3338 Optimize cursor modify
WT-3380 Special case 8-byte timestamps
WT-3387 Add support for a stable timestamp
WT-3389 Restructure split code to hold a split generation for the entire operation.
WT-3406 Reconciliation is choosing reserved records for writing.
WT-3410 Add developer documentation for table rename
WT-3412 Add backoff logic to the btree delete and walk yield loops
WT-3418 block manager object race
WT-3422 WiredTiger upgrading documents out of date
WT-3432 workgen needs braces around an "if" body
WT-3433 session->alter method should not be supported in read-only mode
WT-3439 lint/cleanup
WT-3440 Add a log record when starting a checkpoint
WT-3442 Coverity 1378213: false positive on diagnostic assignment.
WT-3446 Temporarily disable timestamp testing in test/checkpoint
WT-3447 test_stat_log02 can assert before table stats are printed
WT-3461 Avoid long sleeps when the system clock is adjusted
WT-3463 Add recovery of backup to test_timestamp03.py
WT-3466 Track the first commit timestamp for each transaction
WT-3467 Minor lint/cleanup
Diffstat (limited to 'src/third_party/wiredtiger/src/txn/txn_log.c')
-rw-r--r-- | src/third_party/wiredtiger/src/txn/txn_log.c | 95 |
1 files changed, 67 insertions, 28 deletions
diff --git a/src/third_party/wiredtiger/src/txn/txn_log.c b/src/third_party/wiredtiger/src/txn/txn_log.c index d291139284a..1fc74fb53a1 100644 --- a/src/third_party/wiredtiger/src/txn/txn_log.c +++ b/src/third_party/wiredtiger/src/txn/txn_log.c @@ -32,9 +32,9 @@ __txn_op_log_row_key_check(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) memset(&key, 0, sizeof(key)); /* - * We used to take the key for row-store logging from the page - * referenced by the cursor, when we switched to taking it from the - * cursor itself. Check that they are the same. + * We used to take the row-store logging key from the page referenced by + * the cursor, then switched to taking it from the cursor itself. Check + * they are the same. * * If the cursor references a WT_INSERT item, take the key from there, * else take the key from the original page. @@ -50,8 +50,7 @@ __txn_op_log_row_key_check(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) key.size = WT_INSERT_KEY_SIZE(cbt->ins); } - WT_ASSERT(session, - key.size == cursor->key.size && + WT_ASSERT(session, key.size == cursor->key.size && memcmp(key.data, cursor->key.data, key.size) == 0); __wt_buf_free(session, &key); @@ -74,46 +73,62 @@ __txn_op_log(WT_SESSION_IMPL *session, cursor = &cbt->iface; upd = op->u.upd; - value.data = WT_UPDATE_DATA(upd); + value.data = upd->data; value.size = upd->size; /* - * Log the operation. It must be a row- or column-store insert, remove - * or update, all of which require log records. We shouldn't ever log - * reserve operations. + * Log the row- or column-store insert, modify, remove or update. Our + * caller doesn't log reserve operations, we shouldn't see them here. */ - WT_ASSERT(session, upd->type != WT_UPDATE_RESERVED); if (cbt->btree->type == BTREE_ROW) { #ifdef HAVE_DIAGNOSTIC __txn_op_log_row_key_check(session, cbt); #endif - if (upd->type == WT_UPDATE_DELETED) + switch (upd->type) { + case WT_UPDATE_DELETED: WT_RET(__wt_logop_row_remove_pack( session, logrec, op->fileid, &cursor->key)); - else + break; + case WT_UPDATE_MODIFIED: + WT_RET(__wt_logop_row_modify_pack( + session, logrec, op->fileid, &cursor->key, &value)); + break; + case WT_UPDATE_STANDARD: WT_RET(__wt_logop_row_put_pack( session, logrec, op->fileid, &cursor->key, &value)); + break; + WT_ILLEGAL_VALUE(session); + } } else { recno = WT_INSERT_RECNO(cbt->ins); WT_ASSERT(session, recno != WT_RECNO_OOB); - if (upd->type == WT_UPDATE_DELETED) + switch (upd->type) { + case WT_UPDATE_DELETED: WT_RET(__wt_logop_col_remove_pack( session, logrec, op->fileid, recno)); - else + break; + case WT_UPDATE_MODIFIED: + WT_RET(__wt_logop_col_modify_pack( + session, logrec, op->fileid, recno, &value)); + break; + case WT_UPDATE_STANDARD: WT_RET(__wt_logop_col_put_pack( session, logrec, op->fileid, recno, &value)); + break; + WT_ILLEGAL_VALUE(session); + } } return (0); } /* - * __txn_commit_printlog -- - * Print a commit log record. + * __txn_oplist_printlog -- + * Print a list of operations from a log record. */ static int -__txn_commit_printlog(WT_SESSION_IMPL *session, +__txn_oplist_printlog(WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end, uint32_t flags) { bool firstrecord; @@ -344,8 +359,8 @@ __wt_txn_checkpoint_log( WT_TXN *txn; uint8_t *end, *p; size_t recsize; - uint32_t i, rectype = WT_LOGREC_CHECKPOINT; - const char *fmt = WT_UNCHECKED_STRING(IIIIu); + uint32_t i, rectype; + const char *fmt; conn = S2C(session); txn = &session->txn; @@ -367,7 +382,31 @@ __wt_txn_checkpoint_log( switch (flags) { case WT_TXN_LOG_CKPT_PREPARE: txn->full_ckpt = true; - WT_ERR(__wt_log_flush_lsn(session, ckpt_lsn, true)); + + if (conn->compat_major >= WT_LOG_V2) { + /* + * Write the system log record containing a checkpoint + * start operation. + */ + rectype = WT_LOGREC_SYSTEM; + fmt = WT_UNCHECKED_STRING(I); + WT_ERR(__wt_struct_size( + session, &recsize, fmt, rectype)); + WT_ERR(__wt_logrec_alloc(session, recsize, &logrec)); + + WT_ERR(__wt_struct_pack(session, + (uint8_t *)logrec->data + logrec->size, recsize, + fmt, rectype)); + logrec->size += (uint32_t)recsize; + WT_ERR(__wt_logop_checkpoint_start_pack( + session, logrec)); + WT_ERR(__wt_log_write(session, logrec, ckpt_lsn, 0)); + } else { + WT_ERR(__wt_log_printf(session, + "CHECKPOINT: Starting record")); + WT_ERR(__wt_log_flush_lsn(session, ckpt_lsn, true)); + } + /* * We need to make sure that the log records in the checkpoint * LSN are on disk. In particular to make sure that the @@ -401,14 +440,16 @@ __wt_txn_checkpoint_log( ckpt_snapshot = txn->ckpt_snapshot; /* Write the checkpoint log record. */ - WT_ERR(__wt_struct_size(session, &recsize, fmt, - rectype, ckpt_lsn->l.file, ckpt_lsn->l.offset, + rectype = WT_LOGREC_CHECKPOINT; + fmt = WT_UNCHECKED_STRING(IIIIu); + WT_ERR(__wt_struct_size(session, &recsize, + fmt, rectype, ckpt_lsn->l.file, ckpt_lsn->l.offset, txn->ckpt_nsnapshot, ckpt_snapshot)); WT_ERR(__wt_logrec_alloc(session, recsize, &logrec)); WT_ERR(__wt_struct_pack(session, - (uint8_t *)logrec->data + logrec->size, recsize, fmt, - rectype, ckpt_lsn->l.file, ckpt_lsn->l.offset, + (uint8_t *)logrec->data + logrec->size, recsize, + fmt, rectype, ckpt_lsn->l.file, ckpt_lsn->l.offset, txn->ckpt_nsnapshot, ckpt_snapshot)); logrec->size += (uint32_t)recsize; WT_ERR(__wt_log_write(session, logrec, lsnp, @@ -568,7 +609,7 @@ __txn_printlog(WT_SESSION_IMPL *session, " \"type\" : \"commit\",\n")); WT_RET(__wt_fprintf(session, WT_STDOUT(session), " \"txnid\" : %" PRIu64 ",\n", txnid)); - WT_RET(__txn_commit_printlog(session, &p, end, args->flags)); + WT_RET(__txn_oplist_printlog(session, &p, end, args->flags)); break; case WT_LOGREC_FILE_SYNC: @@ -596,9 +637,7 @@ __txn_printlog(WT_SESSION_IMPL *session, WT_UNCHECKED_STRING(II), &lsnfile, &lsnoffset)); WT_RET(__wt_fprintf(session, WT_STDOUT(session), " \"type\" : \"system\",\n")); - WT_RET(__wt_fprintf(session, WT_STDOUT(session), - " \"prev_lsn\" : [%" PRIu32 ",%" PRIu32 "]\n", - lsnfile, lsnoffset)); + WT_RET(__txn_oplist_printlog(session, &p, end, args->flags)); break; } |