Skip to content

Commit

Permalink
Merge pull request #2083 from wiredtiger/log-slot-revamp
Browse files Browse the repository at this point in the history
WT-2031 Log slot revamp
  • Loading branch information
sueloverso committed Aug 27, 2015
2 parents 12044d2 + 71aa73c commit f97cfe9
Show file tree
Hide file tree
Showing 22 changed files with 1,127 additions and 617 deletions.
1 change: 1 addition & 0 deletions dist/flags.py
Expand Up @@ -109,6 +109,7 @@
'SESSION_LOCKED_CHECKPOINT',
'SESSION_LOCKED_HANDLE_LIST',
'SESSION_LOCKED_SCHEMA',
'SESSION_LOCKED_SLOT',
'SESSION_LOCKED_TABLE',
'SESSION_INTERNAL',
'SESSION_LOGGING_INMEM',
Expand Down
5 changes: 5 additions & 0 deletions dist/s_define.list
Expand Up @@ -28,6 +28,11 @@ WT_DEADLOCK
WT_DEBUG_BYTE
WT_HANDLE_CLOSED
WT_HANDLE_NULLABLE
WT_LOG_SLOT_ACTIVE
WT_LOG_SLOT_BITS
WT_LOG_SLOT_MASK_OFF
WT_LOG_SLOT_MASK_ON
WT_LOG_SLOT_MAXBITS
WT_PACKED_STRUCT_BEGIN
WT_PACKED_STRUCT_END
WT_READ_BARRIER
Expand Down
3 changes: 3 additions & 0 deletions dist/s_string.ok
Expand Up @@ -32,6 +32,7 @@ BIGENDIAN
BOOL
BSR
BTREE
BUF
BZ
Barack
Bitfield
Expand Down Expand Up @@ -291,6 +292,7 @@ ULINE
URI
URIs
UTF
Unbuffered
UnixLib
Unmap
UnmapViewOfFile
Expand Down Expand Up @@ -940,6 +942,7 @@ uS
uint
uintmax
unbare
unbuffered
uncompressing
uncompresssed
undef
Expand Down
3 changes: 1 addition & 2 deletions dist/stat_data.py
Expand Up @@ -238,6 +238,7 @@ def __init__(self, name, desc, flags=''):
LogStat('log_compress_small', 'log records too small to compress'),
LogStat('log_compress_writes', 'log records compressed'),
LogStat('log_compress_write_fails', 'log records not compressed'),
LogStat('log_direct_writes', 'log records written directly'),
LogStat('log_max_filesize', 'maximum log file size', 'no_clear,no_scale'),
LogStat('log_prealloc_files', 'pre-allocated log files prepared'),
LogStat('log_prealloc_max',
Expand All @@ -258,8 +259,6 @@ def __init__(self, name, desc, flags=''):
LogStat('log_slot_joins', 'consolidated slot joins'),
LogStat('log_slot_races', 'consolidated slot join races'),
LogStat('log_slot_toobig', 'record size exceeded maximum'),
LogStat('log_slot_toosmall',
'failed to find a slot large enough for record'),
LogStat('log_slot_transitions', 'consolidated slot join transitions'),

##########################################
Expand Down
21 changes: 17 additions & 4 deletions examples/c/ex_log.c
Expand Up @@ -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] */
Expand All @@ -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] */
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
/*
Expand All @@ -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);
/*
Expand All @@ -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] */

/*
Expand All @@ -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);
Expand Down

0 comments on commit f97cfe9

Please sign in to comment.