From 8e2f1d41f35cee84393af30c01323b8e25745728 Mon Sep 17 00:00:00 2001 From: Susan LoVerso Date: Mon, 24 Nov 2014 14:39:39 -0500 Subject: Just pre-allocate log files instead of recycling. #1373 --- dist/api_data.py | 4 +- dist/s_string.ok | 3 +- dist/stat_data.py | 10 ++- src/config/config_def.c | 10 +-- src/conn/conn_log.c | 69 +++++++------------- src/include/connection.h | 6 +- src/include/extern.h | 3 +- src/include/log.h | 8 ++- src/include/stat.h | 7 +- src/include/wiredtiger.in | 114 ++++++++++++++++----------------- src/log/log.c | 158 ++++++++++++++-------------------------------- src/support/stat.c | 17 ++--- tools/stat_data.py | 4 +- 13 files changed, 158 insertions(+), 255 deletions(-) diff --git a/dist/api_data.py b/dist/api_data.py index 2b63704221f..d24f2e3fbea 100644 --- a/dist/api_data.py +++ b/dist/api_data.py @@ -532,8 +532,8 @@ common_wiredtiger_open = [ the path to a directory into which the log files are written. If the value is not an absolute path name, the files are created relative to the database home'''), - Config('recycle', 'true', r''' - recycle rather than remove archived log files''', + Config('prepare', 'true', r''' + prepare pre-allocated log files after archiving''', type='boolean'), ]), Config('mmap', 'true', r''' diff --git a/dist/s_string.ok b/dist/s_string.ok index d7da0cbb135..efb1d9e47e2 100644 --- a/dist/s_string.ok +++ b/dist/s_string.ok @@ -368,12 +368,11 @@ Wformat WinNT WiredTiger WiredTiger's -WiredTigerArchive WiredTigerCheckpoint WiredTigerHome WiredTigerInit WiredTigerLog -WiredTigerRecycle +WiredTigerPreplog WiredTigerStat WiredTigerTxn WithSeeds diff --git a/dist/stat_data.py b/dist/stat_data.py index 43285076630..b21d50df70b 100644 --- a/dist/stat_data.py +++ b/dist/stat_data.py @@ -170,13 +170,11 @@ connection_stats = [ 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,no_scale'), + LogStat('log_prepared_files', 'pre-allocated log files prepared'), + LogStat('log_prepared_max', + 'maximum prepared log files to create', 'no_clear,no_scale'), + LogStat('log_prepared_used', 'prepared log files used'), 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/config/config_def.c b/src/config/config_def.c index 2314653b5f2..82b5ce606fe 100644 --- a/src/config/config_def.c +++ b/src/config/config_def.c @@ -298,7 +298,7 @@ static const WT_CONFIG_CHECK confchk_log_subconfigs[] = { { "enabled", "boolean", NULL, NULL }, { "file_max", "int", "min=100KB,max=2GB", NULL }, { "path", "string", NULL, NULL }, - { "recycle", "boolean", NULL, NULL }, + { "prepare", "boolean", NULL, NULL }, { NULL, NULL, NULL, NULL } }; @@ -655,7 +655,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { "eviction=(threads_max=1,threads_min=1),eviction_dirty_target=80," "eviction_target=80,eviction_trigger=95,exclusive=0,extensions=," "file_extend=,hazard_max=1000,log=(archive=,enabled=0," - "file_max=100MB,path=\"\",recycle=),lsm_manager=(merge=," + "file_max=100MB,path=\"\",prepare=),lsm_manager=(merge=," "worker_thread_max=4),lsm_merge=,mmap=,multiprocess=0," "session_max=100,shared_cache=(chunk=10MB,name=,reserve=0," "size=500MB),statistics=none,statistics_log=(on_close=0," @@ -672,7 +672,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { "eviction=(threads_max=1,threads_min=1),eviction_dirty_target=80," "eviction_target=80,eviction_trigger=95,exclusive=0,extensions=," "file_extend=,hazard_max=1000,log=(archive=,enabled=0," - "file_max=100MB,path=\"\",recycle=),lsm_manager=(merge=," + "file_max=100MB,path=\"\",prepare=),lsm_manager=(merge=," "worker_thread_max=4),lsm_merge=,mmap=,multiprocess=0," "session_max=100,shared_cache=(chunk=10MB,name=,reserve=0," "size=500MB),statistics=none,statistics_log=(on_close=0," @@ -689,7 +689,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { "direct_io=,error_prefix=,eviction=(threads_max=1,threads_min=1)," "eviction_dirty_target=80,eviction_target=80,eviction_trigger=95," "extensions=,file_extend=,hazard_max=1000,log=(archive=,enabled=0" - ",file_max=100MB,path=\"\",recycle=),lsm_manager=(merge=," + ",file_max=100MB,path=\"\",prepare=),lsm_manager=(merge=," "worker_thread_max=4),lsm_merge=,mmap=,multiprocess=0," "session_max=100,shared_cache=(chunk=10MB,name=,reserve=0," "size=500MB),statistics=none,statistics_log=(on_close=0," @@ -705,7 +705,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { "direct_io=,error_prefix=,eviction=(threads_max=1,threads_min=1)," "eviction_dirty_target=80,eviction_target=80,eviction_trigger=95," "extensions=,file_extend=,hazard_max=1000,log=(archive=,enabled=0" - ",file_max=100MB,path=\"\",recycle=),lsm_manager=(merge=," + ",file_max=100MB,path=\"\",prepare=),lsm_manager=(merge=," "worker_thread_max=4),lsm_merge=,mmap=,multiprocess=0," "session_max=100,shared_cache=(chunk=10MB,name=,reserve=0," "size=500MB),statistics=none,statistics_log=(on_close=0," diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c index 5b5411f420a..79e661caa2f 100644 --- a/src/conn/conn_log.c +++ b/src/conn/conn_log.c @@ -66,8 +66,8 @@ __logmgr_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) WT_RET(__wt_config_gets(session, cfg, "log.path", &cval)); WT_RET(__wt_strndup(session, cval.str, cval.len, &conn->log_path)); - WT_RET(__wt_config_gets(session, cfg, "log.recycle", &cval)); - conn->log_recycle = cval.val != 0; + WT_RET(__wt_config_gets(session, cfg, "log.prepare", &cval)); + conn->log_prepare = cval.val != 0; WT_RET(__logmgr_sync_cfg(session, cfg)); return (0); @@ -85,7 +85,7 @@ __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, num_archived, reccount, recycled; + u_int i, locked, logcount, num_archived, reccount, prepared; char **logfiles, **recfiles; conn = S2C(session); @@ -106,7 +106,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file) /* * Main archive code. Get the list of all log files and - * remove or recycle any earlier than the minimum log number. + * remove any earlier than the minimum log number. */ WT_RET(__wt_dirlist(session, conn->log_path, WT_LOG_FILENAME, WT_DIRLIST_INCLUDE, &logfiles, &logcount)); @@ -124,45 +124,44 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file) session, logfiles[i], &lognum)); if (lognum < min_lognum) { num_archived++; - if (conn->log_recycle) - WT_ERR(__wt_log_recycle_rename( - session, lognum)); - else - WT_ERR(__wt_log_remove( - session, WT_LOG_FILENAME, lognum)); + WT_ERR(__wt_log_remove( + session, WT_LOG_FILENAME, lognum)); } } } __wt_spin_unlock(session, &conn->hot_backup_lock); locked = 0; + __wt_log_files_free(session, logfiles, logcount); + logfiles = NULL; + logcount = 0; /* - * If we're recycling the log files, walk the files again and prepare - * them to be reused. We've moved them aside while holding the backup - * lock and now we can process them without the lock. + * If we're preparing the log files, walk the files again and + * pre-allocate up to the maximum number. We do this outside the + * lock. */ - if (conn->log_recycle) { - if (conn->log_recycle_max == 0) { + if (conn->log_prepare) { + if (conn->log_prepared_max == 0) { /* * If checkpoints are based on log size, 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 = + conn->log_prepared_max = (uint32_t)(conn->ckpt_logsize/ conn->log_file_max); else - conn->log_recycle_max = num_archived; + conn->log_prepared_max = WT_LOG_PREP_DEFAULT; } else - conn->log_recycle_max = WT_MAX(conn->log_recycle_max, + conn->log_prepared_max = WT_MAX(conn->log_prepared_max, num_archived); WT_STAT_FAST_CONN_SET(session, - log_recycle_max, conn->log_recycle_max); + log_prepared_max, conn->log_prepared_max); WT_ERR(__wt_dirlist(session, conn->log_path, - WT_LOG_RECYCLENAME, WT_DIRLIST_INCLUDE, + WT_LOG_PREPNAME, WT_DIRLIST_INCLUDE, &recfiles, &reccount)); - recycled = reccount; + prepared = reccount; __wt_log_files_free(session, recfiles, reccount); recfiles = NULL; reccount = 0; @@ -170,34 +169,10 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file) * Recycle up to the maximum number to keep that we just * computed and detected. If we have extra, remove them. */ - for (i = 0; i < logcount; i++) { - WT_ERR(__wt_log_extract_lognum( - session, logfiles[i], &lognum)); - if (lognum < min_lognum) { - if (recycled < conn->log_recycle_max) { - /* - * Keep it. Set it up. - */ - recycled++; - WT_ERR(__wt_log_recycle( - session, lognum)); - } else { - /* - * Extra one. Remove it. - */ - WT_STAT_FAST_CONN_INCR(session, - log_recycle_removed); - WT_ERR(__wt_log_remove( - session, WT_LOG_ARCHNAME, lognum)); - } - } - } + for (i = prepared; i < conn->log_prepared_max; i++) + WT_ERR(__wt_log_prepare(session, ++log->prep_fileid)); } - __wt_log_files_free(session, logfiles, logcount); - logfiles = NULL; - logcount = 0; - /* * Indicate what is our new earliest LSN. It is the start * of the log file containing the last checkpoint. diff --git a/src/include/connection.h b/src/include/connection.h index d9300b319fa..c9f1bda9d10 100644 --- a/src/include/connection.h +++ b/src/include/connection.h @@ -256,9 +256,9 @@ struct __wt_connection_impl { WT_LOG *log; /* Logging structure */ wt_off_t log_file_max; /* Log file max size */ const char *log_path; /* Logging path format */ - int log_recycle; /* Log file recycle configuration */ - /* Maximum recycled log files */ - uint32_t log_recycle_max; + int log_prepare; /* Log file prepare configuration */ + /* Maximum prepared log files */ + uint32_t log_prepared_max; uint32_t txn_logsync; /* Log sync configuration */ WT_SESSION_IMPL *sweep_session; /* Handle sweep session */ diff --git a/src/include/extern.h b/src/include/extern.h index f172a2df712..3cfc4520547 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -315,8 +315,7 @@ extern void __wt_log_written_reset(WT_SESSION_IMPL *session); extern int __wt_log_get_all_files(WT_SESSION_IMPL *session, char ***filesp, u_int *countp, uint32_t *maxid, int active_only); extern void __wt_log_files_free(WT_SESSION_IMPL *session, char **files, u_int count); extern int __wt_log_extract_lognum( WT_SESSION_IMPL *session, const char *name, uint32_t *id); -extern int __wt_log_recycle_rename(WT_SESSION_IMPL *session, uint32_t lognum); -extern int __wt_log_recycle(WT_SESSION_IMPL *session, uint32_t lognum); +extern int __wt_log_prepare(WT_SESSION_IMPL *session, uint32_t lognum); extern int __wt_log_remove(WT_SESSION_IMPL *session, const char *file_prefix, uint32_t lognum); extern int __wt_log_open(WT_SESSION_IMPL *session); extern int __wt_log_close(WT_SESSION_IMPL *session); diff --git a/src/include/log.h b/src/include/log.h index 5d362c60a91..8e5d80740da 100644 --- a/src/include/log.h +++ b/src/include/log.h @@ -5,9 +5,10 @@ * See the file LICENSE for redistribution information. */ -#define WT_LOG_ARCHNAME "WiredTigerArchive" /* Log archived name */ -#define WT_LOG_FILENAME "WiredTigerLog" /* Log file name */ -#define WT_LOG_RECYCLENAME "WiredTigerRecycle" /* Log recycled name */ +#define WT_LOG_FILENAME "WiredTigerLog" /* Log file name */ +#define WT_LOG_PREPNAME "WiredTigerPreplog" /* Log prepared name */ + +#define WT_LOG_PREP_DEFAULT 10 /* Prepare up to 10 files */ /* Logging subsystem declarations. */ #define LOG_ALIGN 128 @@ -103,6 +104,7 @@ typedef struct { * Log file information */ uint32_t fileid; /* Current log file number */ + uint32_t prep_fileid; /* Prepared file number */ WT_FH *log_fh; /* Logging file handle */ WT_FH *log_close_fh; /* Logging file handle to close */ WT_FH *log_dir_fh; /* Log directory file handle */ diff --git a/src/include/stat.h b/src/include/stat.h index 9c1bb493d4b..57d7a1454fc 100644 --- a/src/include/stat.h +++ b/src/include/stat.h @@ -195,11 +195,10 @@ struct __wt_connection_stats { WT_STATS log_bytes_written; WT_STATS log_close_yields; WT_STATS log_max_filesize; + WT_STATS log_prepared_files; + WT_STATS log_prepared_max; + WT_STATS log_prepared_used; 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 986bb4398cc..a55dc6fe675 100644 --- a/src/include/wiredtiger.in +++ b/src/include/wiredtiger.in @@ -1890,8 +1890,8 @@ struct __wt_connection { * which the log files are written. If the value is not an absolute path name\, * the files are created relative to the database home., a string; default \c * "".} - * @config{    recycle, recycle rather than remove - * archived log files., a boolean flag; default \c true.} + * @config{    prepare, prepare pre-allocated log files + * after archiving., a boolean flag; default \c true.} * @config{ ),,} * @config{lsm_manager = (, configure database wide options for LSM tree * management., a set of related configuration options defined below.} @@ -3184,110 +3184,108 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_CONN_LOG_CLOSE_YIELDS 1062 /*! log: maximum log file size */ #define WT_STAT_CONN_LOG_MAX_FILESIZE 1063 +/*! log: pre-allocated log files prepared */ +#define WT_STAT_CONN_LOG_PREPARED_FILES 1064 +/*! log: maximum prepared log files to create */ +#define WT_STAT_CONN_LOG_PREPARED_MAX 1065 +/*! log: prepared log files used */ +#define WT_STAT_CONN_LOG_PREPARED_USED 1066 /*! 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 +#define WT_STAT_CONN_LOG_READS 1067 /*! log: records processed by log scan */ -#define WT_STAT_CONN_LOG_SCAN_RECORDS 1069 +#define WT_STAT_CONN_LOG_SCAN_RECORDS 1068 /*! log: log scan records requiring two reads */ -#define WT_STAT_CONN_LOG_SCAN_REREADS 1070 +#define WT_STAT_CONN_LOG_SCAN_REREADS 1069 /*! log: log scan operations */ -#define WT_STAT_CONN_LOG_SCANS 1071 +#define WT_STAT_CONN_LOG_SCANS 1070 /*! log: consolidated slot closures */ -#define WT_STAT_CONN_LOG_SLOT_CLOSES 1072 +#define WT_STAT_CONN_LOG_SLOT_CLOSES 1071 /*! log: logging bytes consolidated */ -#define WT_STAT_CONN_LOG_SLOT_CONSOLIDATED 1073 +#define WT_STAT_CONN_LOG_SLOT_CONSOLIDATED 1072 /*! log: consolidated slot joins */ -#define WT_STAT_CONN_LOG_SLOT_JOINS 1074 +#define WT_STAT_CONN_LOG_SLOT_JOINS 1073 /*! log: consolidated slot join races */ -#define WT_STAT_CONN_LOG_SLOT_RACES 1075 +#define WT_STAT_CONN_LOG_SLOT_RACES 1074 /*! log: slots selected for switching that were unavailable */ -#define WT_STAT_CONN_LOG_SLOT_SWITCH_FAILS 1076 +#define WT_STAT_CONN_LOG_SLOT_SWITCH_FAILS 1075 /*! log: record size exceeded maximum */ -#define WT_STAT_CONN_LOG_SLOT_TOOBIG 1077 +#define WT_STAT_CONN_LOG_SLOT_TOOBIG 1076 /*! log: failed to find a slot large enough for record */ -#define WT_STAT_CONN_LOG_SLOT_TOOSMALL 1078 +#define WT_STAT_CONN_LOG_SLOT_TOOSMALL 1077 /*! log: consolidated slot join transitions */ -#define WT_STAT_CONN_LOG_SLOT_TRANSITIONS 1079 +#define WT_STAT_CONN_LOG_SLOT_TRANSITIONS 1078 /*! log: log sync operations */ -#define WT_STAT_CONN_LOG_SYNC 1080 +#define WT_STAT_CONN_LOG_SYNC 1079 /*! log: log write operations */ -#define WT_STAT_CONN_LOG_WRITES 1081 +#define WT_STAT_CONN_LOG_WRITES 1080 /*! LSM: sleep for LSM checkpoint throttle */ -#define WT_STAT_CONN_LSM_CHECKPOINT_THROTTLE 1082 +#define WT_STAT_CONN_LSM_CHECKPOINT_THROTTLE 1081 /*! LSM: sleep for LSM merge throttle */ -#define WT_STAT_CONN_LSM_MERGE_THROTTLE 1083 +#define WT_STAT_CONN_LSM_MERGE_THROTTLE 1082 /*! LSM: rows merged in an LSM tree */ -#define WT_STAT_CONN_LSM_ROWS_MERGED 1084 +#define WT_STAT_CONN_LSM_ROWS_MERGED 1083 /*! LSM: application work units currently queued */ -#define WT_STAT_CONN_LSM_WORK_QUEUE_APP 1085 +#define WT_STAT_CONN_LSM_WORK_QUEUE_APP 1084 /*! LSM: merge work units currently queued */ -#define WT_STAT_CONN_LSM_WORK_QUEUE_MANAGER 1086 +#define WT_STAT_CONN_LSM_WORK_QUEUE_MANAGER 1085 /*! LSM: tree queue hit maximum */ -#define WT_STAT_CONN_LSM_WORK_QUEUE_MAX 1087 +#define WT_STAT_CONN_LSM_WORK_QUEUE_MAX 1086 /*! LSM: switch work units currently queued */ -#define WT_STAT_CONN_LSM_WORK_QUEUE_SWITCH 1088 +#define WT_STAT_CONN_LSM_WORK_QUEUE_SWITCH 1087 /*! LSM: tree maintenance operations scheduled */ -#define WT_STAT_CONN_LSM_WORK_UNITS_CREATED 1089 +#define WT_STAT_CONN_LSM_WORK_UNITS_CREATED 1088 /*! LSM: tree maintenance operations discarded */ -#define WT_STAT_CONN_LSM_WORK_UNITS_DISCARDED 1090 +#define WT_STAT_CONN_LSM_WORK_UNITS_DISCARDED 1089 /*! LSM: tree maintenance operations executed */ -#define WT_STAT_CONN_LSM_WORK_UNITS_DONE 1091 +#define WT_STAT_CONN_LSM_WORK_UNITS_DONE 1090 /*! connection: memory allocations */ -#define WT_STAT_CONN_MEMORY_ALLOCATION 1092 +#define WT_STAT_CONN_MEMORY_ALLOCATION 1091 /*! connection: memory frees */ -#define WT_STAT_CONN_MEMORY_FREE 1093 +#define WT_STAT_CONN_MEMORY_FREE 1092 /*! connection: memory re-allocations */ -#define WT_STAT_CONN_MEMORY_GROW 1094 +#define WT_STAT_CONN_MEMORY_GROW 1093 /*! connection: total read I/Os */ -#define WT_STAT_CONN_READ_IO 1095 +#define WT_STAT_CONN_READ_IO 1094 /*! reconciliation: page reconciliation calls */ -#define WT_STAT_CONN_REC_PAGES 1096 +#define WT_STAT_CONN_REC_PAGES 1095 /*! reconciliation: page reconciliation calls for eviction */ -#define WT_STAT_CONN_REC_PAGES_EVICTION 1097 +#define WT_STAT_CONN_REC_PAGES_EVICTION 1096 /*! reconciliation: split bytes currently awaiting free */ -#define WT_STAT_CONN_REC_SPLIT_STASHED_BYTES 1098 +#define WT_STAT_CONN_REC_SPLIT_STASHED_BYTES 1097 /*! reconciliation: split objects currently awaiting free */ -#define WT_STAT_CONN_REC_SPLIT_STASHED_OBJECTS 1099 +#define WT_STAT_CONN_REC_SPLIT_STASHED_OBJECTS 1098 /*! connection: pthread mutex shared lock read-lock calls */ -#define WT_STAT_CONN_RWLOCK_READ 1100 +#define WT_STAT_CONN_RWLOCK_READ 1099 /*! connection: pthread mutex shared lock write-lock calls */ -#define WT_STAT_CONN_RWLOCK_WRITE 1101 +#define WT_STAT_CONN_RWLOCK_WRITE 1100 /*! session: open cursor count */ -#define WT_STAT_CONN_SESSION_CURSOR_OPEN 1102 +#define WT_STAT_CONN_SESSION_CURSOR_OPEN 1101 /*! session: open session count */ -#define WT_STAT_CONN_SESSION_OPEN 1103 +#define WT_STAT_CONN_SESSION_OPEN 1102 /*! transaction: transaction begins */ -#define WT_STAT_CONN_TXN_BEGIN 1104 +#define WT_STAT_CONN_TXN_BEGIN 1103 /*! transaction: transaction checkpoints */ -#define WT_STAT_CONN_TXN_CHECKPOINT 1105 +#define WT_STAT_CONN_TXN_CHECKPOINT 1104 /*! transaction: transaction checkpoint currently running */ -#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1106 +#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1105 /*! transaction: transaction checkpoint max time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1107 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1106 /*! transaction: transaction checkpoint min time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1108 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1107 /*! transaction: transaction checkpoint most recent time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1109 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1108 /*! transaction: transaction checkpoint total time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1110 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1109 /*! transaction: transactions committed */ -#define WT_STAT_CONN_TXN_COMMIT 1111 +#define WT_STAT_CONN_TXN_COMMIT 1110 /*! transaction: transaction failures due to cache overflow */ -#define WT_STAT_CONN_TXN_FAIL_CACHE 1112 +#define WT_STAT_CONN_TXN_FAIL_CACHE 1111 /*! transaction: transaction range of IDs currently pinned */ -#define WT_STAT_CONN_TXN_PINNED_RANGE 1113 +#define WT_STAT_CONN_TXN_PINNED_RANGE 1112 /*! transaction: transactions rolled back */ -#define WT_STAT_CONN_TXN_ROLLBACK 1114 +#define WT_STAT_CONN_TXN_ROLLBACK 1113 /*! connection: total write I/Os */ -#define WT_STAT_CONN_WRITE_IO 1115 +#define WT_STAT_CONN_WRITE_IO 1114 /*! * @} diff --git a/src/log/log.c b/src/log/log.c index 5e617fcc3d7..c8acab3af36 100644 --- a/src/log/log.c +++ b/src/log/log.c @@ -252,7 +252,7 @@ __log_acquire(WT_SESSION_IMPL *session, uint64_t recsize, WT_LOGSLOT *slot) slot->slot_start_offset = log->alloc_lsn.offset; /* * Pre-allocate on the first real write into the log file, if it - * was just created (i.e. not recycled). + * was just created (i.e. not prepared). */ if (log->alloc_lsn.offset == LOG_FIRST_RECORD && created_log) WT_RET(__log_prealloc(session, log->log_fh)); @@ -304,11 +304,11 @@ err: * __log_file_header -- * Create and write a log file header into a file handle. If writing * into the main log, it will be called locked. If writing into a - * recycled log, it will be called unlocked. + * prepared log, it will be called unlocked. */ static int __log_file_header( - WT_SESSION_IMPL *session, WT_FH *fh, WT_LSN *end_lsn, int recycle) + WT_SESSION_IMPL *session, WT_FH *fh, WT_LSN *end_lsn, int prepared) { WT_CONNECTION_IMPL *conn; WT_DECL_ITEM(buf); @@ -352,7 +352,7 @@ __log_file_header( * do not need to call __log_release because we're not waiting for * any earlier operations to complete. */ - if (recycle) { + if (prepared) { WT_ASSERT(session, fh != NULL); tmp.slot_fh = fh; } else { @@ -393,12 +393,12 @@ err: __wt_scr_free(&path); } /* - * __log_alloc_recycle -- - * Look for a recycled log file and rename it to use as the next + * __log_alloc_prepare -- + * Look for a prepared log file and rename it to use as the next * real log file. Called locked. */ static int -__log_alloc_recycle(WT_SESSION_IMPL *session, uint32_t to_num) +__log_alloc_prepare(WT_SESSION_IMPL *session, uint32_t to_num) { WT_DECL_ITEM(from_path); WT_DECL_ITEM(to_path); @@ -408,28 +408,28 @@ __log_alloc_recycle(WT_SESSION_IMPL *session, uint32_t to_num) char **logfiles; /* - * If there are no recyclable files, return WT_NOTFOUND. + * If there are no prepared files, return WT_NOTFOUND. */ logfiles = NULL; WT_ERR(__log_get_files(session, - WT_LOG_RECYCLENAME, &logfiles, &logcount)); + WT_LOG_PREPNAME, &logfiles, &logcount)); if (logcount == 0) return (WT_NOTFOUND); /* - * We have a recycled file to use. Just use the first one. + * We have a file to use. Just use the first one. */ WT_ERR(__wt_log_extract_lognum(session, logfiles[0], &from_num)); WT_ERR(__wt_scr_alloc(session, 0, &from_path)); WT_ERR(__wt_scr_alloc(session, 0, &to_path)); WT_ERR(__log_filename(session, - from_num, WT_LOG_RECYCLENAME, from_path)); + from_num, WT_LOG_PREPNAME, from_path)); WT_ERR(__log_filename(session, to_num, WT_LOG_FILENAME, to_path)); WT_ERR(__wt_verbose(session, WT_VERB_LOG, - "log_alloc_recycle: rename log %s to %s", + "log_alloc_prepare: rename log %s to %s", (char *)from_path->data, (char *)to_path->data)); - WT_STAT_FAST_CONN_INCR(session, log_recycle_reused); + WT_STAT_FAST_CONN_INCR(session, log_prepared_used); /* * All file setup, writing the header and pre-allocation was done * before. We only need to rename it. @@ -443,42 +443,6 @@ err: __wt_scr_free(&from_path); return (ret); } -/* - * __log_reset_file -- - * Reset a recycled log file. Rewrite the file header because the - * log size may have been reconfigured or even the version may have - * changed across a reboot. - */ -static int -__log_reset_file(WT_SESSION_IMPL *session, uint32_t lognum) -{ - WT_CONNECTION_IMPL *conn; - WT_DECL_RET; - WT_FH *log_fh, *tmp_fh; - WT_LOG *log; - - conn = S2C(session); - log = conn->log; - /* - * Resetting a recycled log file entails: - * - Rewriting the header. - * - Truncating to the offset of the first record. - * - Pre-allocating the file if needed. - */ - log_fh = NULL; - WT_ERR(__log_openfile(session, 0, &log_fh, WT_LOG_ARCHNAME, lognum)); - WT_ERR(__log_file_header(session, log_fh, NULL, 1)); - WT_ERR(__wt_ftruncate(session, log_fh, LOG_FIRST_RECORD)); - WT_ERR(__log_prealloc(session, log_fh)); - tmp_fh = log_fh; - log_fh = NULL; - WT_ERR(__wt_close(session, tmp_fh)); - -err: if (log_fh != NULL) - WT_TRET(__wt_close(session, log_fh)); - return (ret); -} - /* * __log_truncate -- * Truncate the log to the given LSN. If this_log is set, it will only @@ -548,59 +512,38 @@ err: if (log_fh != NULL) } /* - * __wt_log_recycle_rename -- - * Given a log number, rename from the log file name to temporary archived - * file name. - */ -int -__wt_log_recycle_rename(WT_SESSION_IMPL *session, uint32_t lognum) -{ - WT_DECL_ITEM(from_path); - WT_DECL_ITEM(to_path); - WT_DECL_RET; - - WT_RET(__wt_scr_alloc(session, 0, &from_path)); - WT_ERR(__wt_scr_alloc(session, 0, &to_path)); - WT_ERR(__log_filename(session, lognum, WT_LOG_FILENAME, from_path)); - WT_ERR(__log_filename(session, lognum, WT_LOG_ARCHNAME, to_path)); - WT_ERR(__wt_verbose(session, WT_VERB_LOG, - "log_recycle_rename: rename log %s to %s", - (char *)from_path->data, (char *)to_path->data)); - WT_ERR(__wt_rename(session, from_path->data, to_path->data)); -err: __wt_scr_free(&from_path); - __wt_scr_free(&to_path); - return (ret); -} - -/* - * __wt_log_recycle -- - * Given a log number of an archived file, recycle that log file by - * clearing it and resetting its truncation. + * __wt_log_prepare -- + * Given an old log number of an archived file, create a new prepared + * log file by resetting its header and pre-allocating it. */ int -__wt_log_recycle(WT_SESSION_IMPL *session, uint32_t lognum) +__wt_log_prepare(WT_SESSION_IMPL *session, uint32_t lognum) { - WT_DECL_ITEM(from_path); - WT_DECL_ITEM(to_path); + WT_CONNECTION_IMPL *conn; WT_DECL_RET; + WT_FH *log_fh, *tmp_fh; + WT_LOG *log; - WT_RET(__wt_scr_alloc(session, 0, &from_path)); - WT_ERR(__wt_scr_alloc(session, 0, &to_path)); - WT_ERR(__log_filename(session, lognum, WT_LOG_ARCHNAME, from_path)); - WT_ERR(__log_filename(session, lognum, WT_LOG_RECYCLENAME, to_path)); - - WT_ERR(__log_reset_file(session, lognum)); + conn = S2C(session); + log = conn->log; /* - * After the file is setup, rename it to the recycle name so that the - * logging subsystem can find it. + * Preparing a log file entails: + * - Writing the header. + * - Truncating to the offset of the first record. + * - Pre-allocating the file if needed. */ - 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); + log_fh = NULL; + WT_ERR(__log_openfile(session, 1, &log_fh, WT_LOG_PREPNAME, lognum)); + WT_ERR(__log_file_header(session, log_fh, NULL, 1)); + WT_ERR(__wt_ftruncate(session, log_fh, LOG_FIRST_RECORD)); + WT_ERR(__log_prealloc(session, log_fh)); + WT_STAT_FAST_CONN_INCR(session, log_prepared_files); + tmp_fh = log_fh; + log_fh = NULL; + WT_ERR(__wt_close(session, tmp_fh)); + +err: if (log_fh != NULL) + WT_TRET(__wt_close(session, log_fh)); return (ret); } @@ -657,22 +600,15 @@ __wt_log_open(WT_SESSION_IMPL *session) 0, 0, WT_FILE_TYPE_DIRECTORY, &log->log_dir_fh)); } /* - * Clean up any old interim archive and recycle files. - * We clean up recycle files because settings have changed upon reboot + * Clean up any old interim prepared files. + * We clean up prepared files because settings have changed upon reboot * and we want those settings to take effect right away. */ - WT_RET(__log_get_files(session, WT_LOG_ARCHNAME, &logfiles, &logcount)); - for (i = 0; i < logcount; i++) { - WT_ERR(__wt_log_extract_lognum(session, logfiles[i], &lognum)); - WT_ERR(__wt_log_remove(session, WT_LOG_ARCHNAME, lognum)); - } - __wt_log_files_free(session, logfiles, logcount); - logfiles = NULL; WT_ERR(__log_get_files(session, - WT_LOG_RECYCLENAME, &logfiles, &logcount)); + WT_LOG_PREPNAME, &logfiles, &logcount)); for (i = 0; i < logcount; i++) { WT_ERR(__wt_log_extract_lognum(session, logfiles[i], &lognum)); - WT_ERR(__wt_log_remove(session, WT_LOG_RECYCLENAME, lognum)); + WT_ERR(__wt_log_remove(session, WT_LOG_PREPNAME, lognum)); } __wt_log_files_free(session, logfiles, logcount); logfiles = NULL; @@ -984,12 +920,12 @@ __wt_log_newfile(WT_SESSION_IMPL *session, int conn_create, int *created) log->fileid++; /* - * If we're recycling log files, look for one. If there aren't any - * or we're not recycling, then create one. + * If we're pre-allocating log files, look for one. If there aren't any + * or we're not pre-allocating, then create one. */ ret = 0; - if (conn->log_recycle) { - ret = __log_alloc_recycle(session, log->fileid); + if (conn->log_prepare) { + ret = __log_alloc_prepare(session, log->fileid); /* * If ret is 0 it means we reused a file and we don't send the * create flag to __log_openfile. @@ -1010,7 +946,7 @@ __wt_log_newfile(WT_SESSION_IMPL *session, int conn_create, int *created) create_log, &log->log_fh, WT_LOG_FILENAME, log->fileid)); /* * If we created the log, write a header. Otherwise it's already there. - * We need to setup the LSNs. If we're using a recycled log file, + * We need to setup the LSNs. If we're using a prepared log file, * set the end LSN and alloc LSN to the end of the header because the * header is already in the file. Otherwise it will be filled in * when writing to the log file and the LSN values will be updated. diff --git a/src/support/stat.c b/src/support/stat.c index d3f9c1f06f8..888514c01dd 100644 --- a/src/support/stat.c +++ b/src/support/stat.c @@ -404,10 +404,6 @@ __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 = @@ -426,11 +422,13 @@ __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_prepared_max.desc = + "log: maximum prepared log files to create"; + stats->log_prepared_files.desc = + "log: pre-allocated log files prepared"; + stats->log_prepared_used.desc = "log: prepared log files used"; 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"; @@ -549,8 +547,6 @@ __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; @@ -565,9 +561,10 @@ __wt_stat_refresh_connection_stats(void *stats_arg) stats->log_sync.v = 0; stats->log_writes.v = 0; stats->log_slot_consolidated.v = 0; + stats->log_prepared_files.v = 0; + stats->log_prepared_used.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 93e0c03a9cb..6abbbf45233 100644 --- a/tools/stat_data.py +++ b/tools/stat_data.py @@ -9,7 +9,7 @@ no_scale_per_second_list = [ 'cache: tracked dirty pages in the cache', 'connection: files currently open', 'log: maximum log file size', - 'log: maximum recycled log files to keep', + 'log: maximum prepared log files to create', 'log: total log buffer size', 'LSM: application work units currently queued', 'LSM: merge work units currently queued', @@ -58,7 +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: maximum prepared log files to create', 'log: total log buffer size', 'LSM: application work units currently queued', 'LSM: merge work units currently queued', -- cgit v1.2.1