diff options
author | Susan LoVerso <sue@wiredtiger.com> | 2015-08-05 12:50:47 -0400 |
---|---|---|
committer | Susan LoVerso <sue@wiredtiger.com> | 2015-08-05 12:50:47 -0400 |
commit | e81aa9dfec12a48b3090fe01b31c3631a1d43b6f (patch) | |
tree | 243c4d0e0d4bb029c56c150105cde19f9a7e7c02 /examples | |
parent | 0f64ae7471900bffdea2c93de1d7f1b9b712a3c1 (diff) | |
download | mongo-e81aa9dfec12a48b3090fe01b31c3631a1d43b6f.tar.gz |
WT-2031 ex_log debugging
Diffstat (limited to 'examples')
-rw-r--r-- | examples/c/ex_log.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/examples/c/ex_log.c b/examples/c/ex_log.c index 136cca900cd..875f73a8c24 100644 --- a/examples/c/ex_log.c +++ b/examples/c/ex_log.c @@ -128,20 +128,22 @@ print_record(WT_LSN *lsn, uint32_t opcount, * A simple walk of the log. */ static int -simple_walk_log(WT_SESSION *session) +simple_walk_log(WT_SESSION *session, int count_min) { WT_CURSOR *cursor; WT_LSN lsn; WT_ITEM logrec_key, logrec_value; uint64_t txnid; uint32_t fileid, opcount, optype, rectype; - int ret; + int count, ret; /*! [log cursor open] */ ret = session->open_cursor(session, "log:", NULL, NULL, &cursor); /*! [log cursor open] */ + count = 0; while ((ret = cursor->next(cursor)) == 0) { + count++; /*! [log cursor get_key] */ ret = cursor->get_key(cursor, &lsn.file, &lsn.offset, &opcount); /*! [log cursor get_key] */ @@ -156,6 +158,12 @@ simple_walk_log(WT_SESSION *session) if (ret == WT_NOTFOUND) ret = 0; ret = cursor->close(cursor); + if (count < count_min) { + fprintf(stderr, + "Expected minimum %d records, found %d\n", + count_min, count); + abort(); + } return (ret); } /*! [log cursor walk] */ @@ -276,9 +284,10 @@ main(void) WT_CONNECTION *wt_conn; WT_CURSOR *cursor; WT_SESSION *session; - int i, record_count, ret; + int count_min, i, record_count, ret; char cmd_buf[256], k[16], v[16]; + count_min = 0; snprintf(cmd_buf, sizeof(cmd_buf), "rm -rf %s %s && mkdir %s %s", home1, home2, home1, home2); if ((ret = system(cmd_buf)) != 0) { @@ -293,6 +302,7 @@ main(void) ret = wt_conn->open_session(wt_conn, NULL, NULL, &session); ret = session->create(session, uri, "key_format=S,value_format=S"); + count_min++; ret = session->open_cursor(session, uri, NULL, NULL, &cursor); /* @@ -304,6 +314,7 @@ main(void) cursor->set_key(cursor, k); cursor->set_value(cursor, v); ret = cursor->insert(cursor); + count_min++; } ret = session->begin_transaction(session, NULL); /* @@ -317,10 +328,12 @@ main(void) ret = cursor->insert(cursor); } ret = session->commit_transaction(session, NULL); + count_min++; ret = cursor->close(cursor); /*! [log cursor printf] */ ret = session->log_printf(session, "Wrote %d records", record_count); + count_min++; /*! [log cursor printf] */ /* @@ -336,7 +349,7 @@ main(void) } ret = wt_conn->open_session(wt_conn, NULL, NULL, &session); - ret = simple_walk_log(session); + ret = simple_walk_log(session, count_min); ret = walk_log(session); ret = wt_conn->close(wt_conn, NULL); return (ret); |