summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSusan LoVerso <sue@wiredtiger.com>2014-11-20 10:09:45 -0500
committerSusan LoVerso <sue@wiredtiger.com>2014-11-20 10:09:45 -0500
commit627b7e2e17915093af0b621119cc9a1ee563bab7 (patch)
tree1906d1d776b086ff331174cad6f4113313c73b73
parent06d42a28a34f801991bff90b10a72de71b557210 (diff)
downloadmongo-627b7e2e17915093af0b621119cc9a1ee563bab7.tar.gz
Add recycle stats and code to set a maximum number of recycle files.
-rw-r--r--dist/stat_data.py8
-rw-r--r--src/conn/conn_log.c54
-rw-r--r--src/include/connection.h4
-rw-r--r--src/include/stat.h4
-rw-r--r--src/include/wiredtiger.in102
-rw-r--r--src/log/log.c2
-rw-r--r--src/support/stat.c10
-rw-r--r--tools/stat_data.py3
8 files changed, 130 insertions, 57 deletions
diff --git a/dist/stat_data.py b/dist/stat_data.py
index df6c919f808..43285076630 100644
--- a/dist/stat_data.py
+++ b/dist/stat_data.py
@@ -169,8 +169,14 @@ connection_stats = [
LogStat('log_bytes_payload', 'log bytes of payload data'),
LogStat('log_bytes_written', 'log bytes written'),
LogStat('log_close_yields', 'yields waiting for previous log file close'),
- LogStat('log_max_filesize', 'maximum log file size', 'no_clear'),
+ LogStat('log_max_filesize', 'maximum log file size', 'no_clear,no_scale'),
LogStat('log_reads', 'log read operations'),
+ LogStat('log_recycle_files', 'archived log files prepared for recycling'),
+ LogStat('log_recycle_max',
+ 'maximum recycled log files to keep', 'no_clear,no_scale'),
+ LogStat('log_recycle_removed',
+ 'archived log files removed over recycle limit'),
+ LogStat('log_recycle_reused', 'recycled log files reused'),
LogStat('log_scan_records', 'records processed by log scan'),
LogStat('log_scan_rereads', 'log scan records requiring two reads'),
LogStat('log_scans', 'log scan operations'),
diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c
index 06ab802bbfc..341ce4bd101 100644
--- a/src/conn/conn_log.c
+++ b/src/conn/conn_log.c
@@ -85,13 +85,13 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
WT_DECL_RET;
WT_LOG *log;
uint32_t lognum, min_lognum;
- u_int i, locked, logcount;
- char **logfiles;
+ u_int i, locked, logcount, num_archived, reccount, recycled;
+ char **logfiles, **recfiles;
conn = S2C(session);
log = conn->log;
- logcount = 0;
- logfiles = NULL;
+ logcount = num_archived = reccount = 0;
+ logfiles = recfiles = NULL;
/*
* If we're coming from a backup cursor we want the smaller of
@@ -118,10 +118,12 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
__wt_spin_lock(session, &conn->hot_backup_lock);
locked = 1;
if (conn->hot_backup == 0 || backup_file != 0) {
+ num_archived = 0;
for (i = 0; i < logcount; i++) {
WT_ERR(__wt_log_extract_lognum(
session, logfiles[i], &lognum));
if (lognum < min_lognum) {
+ num_archived++;
if (conn->log_recycle)
WT_ERR(__wt_log_recycle_rename(
session, lognum));
@@ -139,14 +141,48 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
* them to be reused. We've moved them aside while holding the backup
* lock and now we can process them without the lock.
*/
- if (conn->log_recycle)
+ if (conn->log_recycle) {
+ if (conn->log_recycle_max == 0) {
+ /*
+ * If checkpoints based on log size are set, use that
+ * as the number of log files to keep. Otherwise
+ * compute it based on how many we just archived.
+ */
+ if (WT_CKPT_LOGSIZE(conn))
+ conn->log_recycle_max =
+ (uint32_t)(conn->ckpt_logsize/
+ conn->log_file_max);
+ else
+ conn->log_recycle_max = num_archived;
+ } else
+ conn->log_recycle_max = WT_MAX(conn->log_recycle_max,
+ num_archived);
+ WT_STAT_FAST_CONN_SET(session,
+ log_recycle_max, conn->log_recycle_max);
+ WT_ERR(__wt_dirlist(session, conn->log_path,
+ WT_LOG_RECYCLENAME, WT_DIRLIST_INCLUDE,
+ &recfiles, &reccount));
+ recycled = reccount;
+ __wt_log_files_free(session, recfiles, reccount);
+ recfiles = NULL;
+ reccount = 0;
for (i = 0; i < logcount; i++) {
WT_ERR(__wt_log_extract_lognum(
session, logfiles[i], &lognum));
- if (lognum < min_lognum)
- WT_ERR(__wt_log_recycle(
- session, lognum));
+ if (lognum < min_lognum) {
+ if (recycled < conn->log_recycle_max) {
+ recycled++;
+ WT_ERR(__wt_log_recycle(
+ session, lognum));
+ } else {
+ WT_STAT_FAST_CONN_INCR(session,
+ log_recycle_removed);
+ WT_ERR(__wt_log_remove(
+ session, WT_LOG_ARCHNAME, lognum));
+ }
+ }
}
+ }
__wt_log_files_free(session, logfiles, logcount);
logfiles = NULL;
@@ -166,6 +202,8 @@ err: __wt_err(session, ret, "log archive server error");
__wt_spin_unlock(session, &conn->hot_backup_lock);
if (logfiles != NULL)
__wt_log_files_free(session, logfiles, logcount);
+ if (recfiles != NULL)
+ __wt_log_files_free(session, recfiles, reccount);
return (ret);
}
diff --git a/src/include/connection.h b/src/include/connection.h
index 14ce115e399..d9300b319fa 100644
--- a/src/include/connection.h
+++ b/src/include/connection.h
@@ -257,7 +257,9 @@ struct __wt_connection_impl {
wt_off_t log_file_max; /* Log file max size */
const char *log_path; /* Logging path format */
int log_recycle; /* Log file recycle configuration */
- uint32_t txn_logsync; /* Log sync configuration */
+ /* Maximum recycled log files */
+ uint32_t log_recycle_max;
+ uint32_t txn_logsync; /* Log sync configuration */
WT_SESSION_IMPL *sweep_session; /* Handle sweep session */
wt_thread_t sweep_tid; /* Handle sweep thread */
diff --git a/src/include/stat.h b/src/include/stat.h
index ee2baa9037b..9c1bb493d4b 100644
--- a/src/include/stat.h
+++ b/src/include/stat.h
@@ -196,6 +196,10 @@ struct __wt_connection_stats {
WT_STATS log_close_yields;
WT_STATS log_max_filesize;
WT_STATS log_reads;
+ WT_STATS log_recycle_files;
+ WT_STATS log_recycle_max;
+ WT_STATS log_recycle_removed;
+ WT_STATS log_recycle_reused;
WT_STATS log_scan_records;
WT_STATS log_scan_rereads;
WT_STATS log_scans;
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index 08a0837fba5..41c08f9b58b 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -3186,100 +3186,108 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection);
#define WT_STAT_CONN_LOG_MAX_FILESIZE 1063
/*! log: log read operations */
#define WT_STAT_CONN_LOG_READS 1064
+/*! log: archived log files prepared for recycling */
+#define WT_STAT_CONN_LOG_RECYCLE_FILES 1065
+/*! log: maximum recycled log files to keep */
+#define WT_STAT_CONN_LOG_RECYCLE_MAX 1066
+/*! log: archived log files removed over recycle limit */
+#define WT_STAT_CONN_LOG_RECYCLE_REMOVED 1067
+/*! log: recycled log files reused */
+#define WT_STAT_CONN_LOG_RECYCLE_REUSED 1068
/*! log: records processed by log scan */
-#define WT_STAT_CONN_LOG_SCAN_RECORDS 1065
+#define WT_STAT_CONN_LOG_SCAN_RECORDS 1069
/*! log: log scan records requiring two reads */
-#define WT_STAT_CONN_LOG_SCAN_REREADS 1066
+#define WT_STAT_CONN_LOG_SCAN_REREADS 1070
/*! log: log scan operations */
-#define WT_STAT_CONN_LOG_SCANS 1067
+#define WT_STAT_CONN_LOG_SCANS 1071
/*! log: consolidated slot closures */
-#define WT_STAT_CONN_LOG_SLOT_CLOSES 1068
+#define WT_STAT_CONN_LOG_SLOT_CLOSES 1072
/*! log: logging bytes consolidated */
-#define WT_STAT_CONN_LOG_SLOT_CONSOLIDATED 1069
+#define WT_STAT_CONN_LOG_SLOT_CONSOLIDATED 1073
/*! log: consolidated slot joins */
-#define WT_STAT_CONN_LOG_SLOT_JOINS 1070
+#define WT_STAT_CONN_LOG_SLOT_JOINS 1074
/*! log: consolidated slot join races */
-#define WT_STAT_CONN_LOG_SLOT_RACES 1071
+#define WT_STAT_CONN_LOG_SLOT_RACES 1075
/*! log: slots selected for switching that were unavailable */
-#define WT_STAT_CONN_LOG_SLOT_SWITCH_FAILS 1072
+#define WT_STAT_CONN_LOG_SLOT_SWITCH_FAILS 1076
/*! log: record size exceeded maximum */
-#define WT_STAT_CONN_LOG_SLOT_TOOBIG 1073
+#define WT_STAT_CONN_LOG_SLOT_TOOBIG 1077
/*! log: failed to find a slot large enough for record */
-#define WT_STAT_CONN_LOG_SLOT_TOOSMALL 1074
+#define WT_STAT_CONN_LOG_SLOT_TOOSMALL 1078
/*! log: consolidated slot join transitions */
-#define WT_STAT_CONN_LOG_SLOT_TRANSITIONS 1075
+#define WT_STAT_CONN_LOG_SLOT_TRANSITIONS 1079
/*! log: log sync operations */
-#define WT_STAT_CONN_LOG_SYNC 1076
+#define WT_STAT_CONN_LOG_SYNC 1080
/*! log: log write operations */
-#define WT_STAT_CONN_LOG_WRITES 1077
+#define WT_STAT_CONN_LOG_WRITES 1081
/*! LSM: sleep for LSM checkpoint throttle */
-#define WT_STAT_CONN_LSM_CHECKPOINT_THROTTLE 1078
+#define WT_STAT_CONN_LSM_CHECKPOINT_THROTTLE 1082
/*! LSM: sleep for LSM merge throttle */
-#define WT_STAT_CONN_LSM_MERGE_THROTTLE 1079
+#define WT_STAT_CONN_LSM_MERGE_THROTTLE 1083
/*! LSM: rows merged in an LSM tree */
-#define WT_STAT_CONN_LSM_ROWS_MERGED 1080
+#define WT_STAT_CONN_LSM_ROWS_MERGED 1084
/*! LSM: application work units currently queued */
-#define WT_STAT_CONN_LSM_WORK_QUEUE_APP 1081
+#define WT_STAT_CONN_LSM_WORK_QUEUE_APP 1085
/*! LSM: merge work units currently queued */
-#define WT_STAT_CONN_LSM_WORK_QUEUE_MANAGER 1082
+#define WT_STAT_CONN_LSM_WORK_QUEUE_MANAGER 1086
/*! LSM: tree queue hit maximum */
-#define WT_STAT_CONN_LSM_WORK_QUEUE_MAX 1083
+#define WT_STAT_CONN_LSM_WORK_QUEUE_MAX 1087
/*! LSM: switch work units currently queued */
-#define WT_STAT_CONN_LSM_WORK_QUEUE_SWITCH 1084
+#define WT_STAT_CONN_LSM_WORK_QUEUE_SWITCH 1088
/*! LSM: tree maintenance operations scheduled */
-#define WT_STAT_CONN_LSM_WORK_UNITS_CREATED 1085
+#define WT_STAT_CONN_LSM_WORK_UNITS_CREATED 1089
/*! LSM: tree maintenance operations discarded */
-#define WT_STAT_CONN_LSM_WORK_UNITS_DISCARDED 1086
+#define WT_STAT_CONN_LSM_WORK_UNITS_DISCARDED 1090
/*! LSM: tree maintenance operations executed */
-#define WT_STAT_CONN_LSM_WORK_UNITS_DONE 1087
+#define WT_STAT_CONN_LSM_WORK_UNITS_DONE 1091
/*! connection: memory allocations */
-#define WT_STAT_CONN_MEMORY_ALLOCATION 1088
+#define WT_STAT_CONN_MEMORY_ALLOCATION 1092
/*! connection: memory frees */
-#define WT_STAT_CONN_MEMORY_FREE 1089
+#define WT_STAT_CONN_MEMORY_FREE 1093
/*! connection: memory re-allocations */
-#define WT_STAT_CONN_MEMORY_GROW 1090
+#define WT_STAT_CONN_MEMORY_GROW 1094
/*! connection: total read I/Os */
-#define WT_STAT_CONN_READ_IO 1091
+#define WT_STAT_CONN_READ_IO 1095
/*! reconciliation: page reconciliation calls */
-#define WT_STAT_CONN_REC_PAGES 1092
+#define WT_STAT_CONN_REC_PAGES 1096
/*! reconciliation: page reconciliation calls for eviction */
-#define WT_STAT_CONN_REC_PAGES_EVICTION 1093
+#define WT_STAT_CONN_REC_PAGES_EVICTION 1097
/*! reconciliation: split bytes currently awaiting free */
-#define WT_STAT_CONN_REC_SPLIT_STASHED_BYTES 1094
+#define WT_STAT_CONN_REC_SPLIT_STASHED_BYTES 1098
/*! reconciliation: split objects currently awaiting free */
-#define WT_STAT_CONN_REC_SPLIT_STASHED_OBJECTS 1095
+#define WT_STAT_CONN_REC_SPLIT_STASHED_OBJECTS 1099
/*! connection: pthread mutex shared lock read-lock calls */
-#define WT_STAT_CONN_RWLOCK_READ 1096
+#define WT_STAT_CONN_RWLOCK_READ 1100
/*! connection: pthread mutex shared lock write-lock calls */
-#define WT_STAT_CONN_RWLOCK_WRITE 1097
+#define WT_STAT_CONN_RWLOCK_WRITE 1101
/*! session: open cursor count */
-#define WT_STAT_CONN_SESSION_CURSOR_OPEN 1098
+#define WT_STAT_CONN_SESSION_CURSOR_OPEN 1102
/*! session: open session count */
-#define WT_STAT_CONN_SESSION_OPEN 1099
+#define WT_STAT_CONN_SESSION_OPEN 1103
/*! transaction: transaction begins */
-#define WT_STAT_CONN_TXN_BEGIN 1100
+#define WT_STAT_CONN_TXN_BEGIN 1104
/*! transaction: transaction checkpoints */
-#define WT_STAT_CONN_TXN_CHECKPOINT 1101
+#define WT_STAT_CONN_TXN_CHECKPOINT 1105
/*! transaction: transaction checkpoint currently running */
-#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1102
+#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1106
/*! transaction: transaction checkpoint max time (msecs) */
-#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1103
+#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1107
/*! transaction: transaction checkpoint min time (msecs) */
-#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1104
+#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1108
/*! transaction: transaction checkpoint most recent time (msecs) */
-#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1105
+#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1109
/*! transaction: transaction checkpoint total time (msecs) */
-#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1106
+#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1110
/*! transaction: transactions committed */
-#define WT_STAT_CONN_TXN_COMMIT 1107
+#define WT_STAT_CONN_TXN_COMMIT 1111
/*! transaction: transaction failures due to cache overflow */
-#define WT_STAT_CONN_TXN_FAIL_CACHE 1108
+#define WT_STAT_CONN_TXN_FAIL_CACHE 1112
/*! transaction: transaction range of IDs currently pinned */
-#define WT_STAT_CONN_TXN_PINNED_RANGE 1109
+#define WT_STAT_CONN_TXN_PINNED_RANGE 1113
/*! transaction: transactions rolled back */
-#define WT_STAT_CONN_TXN_ROLLBACK 1110
+#define WT_STAT_CONN_TXN_ROLLBACK 1114
/*! connection: total write I/Os */
-#define WT_STAT_CONN_WRITE_IO 1111
+#define WT_STAT_CONN_WRITE_IO 1115
/*!
* @}
diff --git a/src/log/log.c b/src/log/log.c
index 60c1c34bc9e..1982b7a54e7 100644
--- a/src/log/log.c
+++ b/src/log/log.c
@@ -426,6 +426,7 @@ __log_alloc_recycle(WT_SESSION_IMPL *session, uint32_t to_num)
WT_ERR(__wt_verbose(session, WT_VERB_LOG,
"log_alloc_recycle: rename log %s to %s",
(char *)from_path->data, (char *)to_path->data));
+ WT_STAT_FAST_CONN_INCR(session, log_recycle_reused);
WT_ERR(__wt_rename(session, from_path->data, to_path->data));
err: __wt_scr_free(&from_path);
@@ -588,6 +589,7 @@ __wt_log_recycle(WT_SESSION_IMPL *session, uint32_t lognum)
WT_ERR(__wt_verbose(session, WT_VERB_LOG,
"log_recycle: recycle log %s to %s",
(char *)from_path->data, (char *)to_path->data));
+ WT_STAT_FAST_CONN_INCR(session, log_recycle_files);
WT_ERR(__wt_rename(session, from_path->data, to_path->data));
err: __wt_scr_free(&from_path);
__wt_scr_free(&to_path);
diff --git a/src/support/stat.c b/src/support/stat.c
index 2b53746bb46..d3f9c1f06f8 100644
--- a/src/support/stat.c
+++ b/src/support/stat.c
@@ -404,6 +404,10 @@ __wt_stat_init_connection_stats(WT_CONNECTION_STATS *stats)
stats->write_io.desc = "connection: total write I/Os";
stats->dh_session_handles.desc = "data-handle: session dhandles swept";
stats->dh_session_sweeps.desc = "data-handle: session sweep attempts";
+ stats->log_recycle_files.desc =
+ "log: archived log files prepared for recycling";
+ stats->log_recycle_removed.desc =
+ "log: archived log files removed over recycle limit";
stats->log_slot_closes.desc = "log: consolidated slot closures";
stats->log_slot_races.desc = "log: consolidated slot join races";
stats->log_slot_transitions.desc =
@@ -422,8 +426,11 @@ __wt_stat_init_connection_stats(WT_CONNECTION_STATS *stats)
stats->log_writes.desc = "log: log write operations";
stats->log_slot_consolidated.desc = "log: logging bytes consolidated";
stats->log_max_filesize.desc = "log: maximum log file size";
+ stats->log_recycle_max.desc =
+ "log: maximum recycled log files to keep";
stats->log_slot_toobig.desc = "log: record size exceeded maximum";
stats->log_scan_records.desc = "log: records processed by log scan";
+ stats->log_recycle_reused.desc = "log: recycled log files reused";
stats->log_slot_switch_fails.desc =
"log: slots selected for switching that were unavailable";
stats->log_buffer_size.desc = "log: total log buffer size";
@@ -542,6 +549,8 @@ __wt_stat_refresh_connection_stats(void *stats_arg)
stats->write_io.v = 0;
stats->dh_session_handles.v = 0;
stats->dh_session_sweeps.v = 0;
+ stats->log_recycle_files.v = 0;
+ stats->log_recycle_removed.v = 0;
stats->log_slot_closes.v = 0;
stats->log_slot_races.v = 0;
stats->log_slot_transitions.v = 0;
@@ -558,6 +567,7 @@ __wt_stat_refresh_connection_stats(void *stats_arg)
stats->log_slot_consolidated.v = 0;
stats->log_slot_toobig.v = 0;
stats->log_scan_records.v = 0;
+ stats->log_recycle_reused.v = 0;
stats->log_slot_switch_fails.v = 0;
stats->log_close_yields.v = 0;
stats->lsm_rows_merged.v = 0;
diff --git a/tools/stat_data.py b/tools/stat_data.py
index 56218f497b7..93e0c03a9cb 100644
--- a/tools/stat_data.py
+++ b/tools/stat_data.py
@@ -8,6 +8,8 @@ no_scale_per_second_list = [
'cache: tracked dirty bytes in the cache',
'cache: tracked dirty pages in the cache',
'connection: files currently open',
+ 'log: maximum log file size',
+ 'log: maximum recycled log files to keep',
'log: total log buffer size',
'LSM: application work units currently queued',
'LSM: merge work units currently queued',
@@ -56,6 +58,7 @@ no_clear_list = [
'cache: pages currently held in the cache',
'connection: files currently open',
'log: maximum log file size',
+ 'log: maximum recycled log files to keep',
'log: total log buffer size',
'LSM: application work units currently queued',
'LSM: merge work units currently queued',