Navigation Menu

Skip to content

Commit

Permalink
WT-2007 Cap slot buffer size to max log file size.
Browse files Browse the repository at this point in the history
  • Loading branch information
sueloverso committed Jul 14, 2015
1 parent f148e05 commit 7dac998
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/include/log.h
Expand Up @@ -161,6 +161,7 @@ typedef struct {
uint32_t pool_index; /* Global pool index */
WT_LOGSLOT *slot_array[WT_SLOT_ACTIVE]; /* Active slots */
WT_LOGSLOT slot_pool[WT_SLOT_POOL]; /* Pool of all slots */
wt_off_t slot_buf_size; /* Buffer size for slots */

#define WT_LOG_FORCE_CONSOLIDATE 0x01 /* Disable direct writes */
uint32_t flags;
Expand Down
11 changes: 8 additions & 3 deletions src/log/log_slot.c
Expand Up @@ -54,13 +54,17 @@ __wt_log_slot_init(WT_SESSION_IMPL *session)
* Allocate memory for buffers now that the arrays are setup. Split
* this out to make error handling simpler.
*/
/*
* Cap the slot buffer to the log file size.
*/
log->slot_buf_size = WT_MIN(conn->log_file_max, WT_LOG_SLOT_BUF_SIZE);
for (i = 0; i < WT_SLOT_POOL; i++) {
WT_ERR(__wt_buf_init(session,
&log->slot_pool[i].slot_buf, WT_LOG_SLOT_BUF_SIZE));
&log->slot_pool[i].slot_buf, log->slot_buf_size));
F_SET(&log->slot_pool[i], WT_SLOT_INIT_FLAGS);
}
WT_STAT_FAST_CONN_INCRV(session,
log_buffer_size, WT_LOG_SLOT_BUF_SIZE * WT_SLOT_POOL);
log_buffer_size, log->slot_buf_size * WT_SLOT_POOL);
if (0) {
err: while (--i >= 0)
__wt_buf_free(session, &log->slot_pool[i].slot_buf);
Expand Down Expand Up @@ -106,7 +110,7 @@ __wt_log_slot_join(WT_SESSION_IMPL *session, uint64_t mysize,
conn = S2C(session);
log = conn->log;

if (mysize >= WT_LOG_SLOT_BUF_SIZE) {
if (mysize >= (uint64_t)log->slot_buf_size) {
WT_STAT_FAST_CONN_INCR(session, log_slot_toobig);
return (ENOMEM);
}
Expand Down Expand Up @@ -311,6 +315,7 @@ __wt_log_slot_free(WT_SESSION_IMPL *session, WT_LOGSLOT *slot)
{
WT_DECL_RET;

WT_UNUSED(session);
ret = 0;
/*
* Make sure flags don't get retained between uses.
Expand Down

0 comments on commit 7dac998

Please sign in to comment.