diff options
author | Michael Cahill <mjc@wiredtiger.com> | 2014-06-20 10:38:10 +1000 |
---|---|---|
committer | Michael Cahill <mjc@wiredtiger.com> | 2014-06-20 10:38:10 +1000 |
commit | 402de76b40eb17fac9523292bc6fc4689a91a73d (patch) | |
tree | c97cc68afd65363c510042470ee186ace66ed8d8 | |
parent | 5fe0eebc3b7781f81c41c516682c1542f97bec1a (diff) | |
parent | 083ec47d5d2d6a6abf7d795bb7bf2cf1e0481871 (diff) | |
download | mongo-402de76b40eb17fac9523292bc6fc4689a91a73d.tar.gz |
Merge pull request #1076 from wiredtiger/txn-sync
Add per-txn sync configuration support. #1074
-rw-r--r-- | dist/api_config.py | 44 | ||||
-rw-r--r-- | dist/api_data.py | 17 | ||||
-rw-r--r-- | dist/flags.py | 13 | ||||
-rw-r--r-- | src/config/config_def.c | 310 | ||||
-rw-r--r-- | src/conn/conn_log.c | 56 | ||||
-rw-r--r-- | src/docs/upgrading.dox | 11 | ||||
-rw-r--r-- | src/include/flags.h | 3 | ||||
-rw-r--r-- | src/include/txn.h | 1 | ||||
-rw-r--r-- | src/include/wiredtiger.in | 15 | ||||
-rw-r--r-- | src/txn/txn.c | 10 | ||||
-rw-r--r-- | src/txn/txn_log.c | 2 | ||||
-rw-r--r-- | test/suite/test_txn02.py | 10 | ||||
-rw-r--r-- | test/suite/test_txn04.py | 7 | ||||
-rw-r--r-- | test/suite/test_txn05.py | 7 |
14 files changed, 291 insertions, 215 deletions
diff --git a/dist/api_config.py b/dist/api_config.py index 7c37abdfe4f..46a2f94f061 100644 --- a/dist/api_config.py +++ b/dist/api_config.py @@ -85,11 +85,12 @@ def getconfcheck(c): # Manually re-wrap when there is a check string to avoid ugliness # between string and non-string wrapping if len(check + ' ' + cstr + ',\n\t ' + sstr + '},') >= 68: - check = check + '\n\t ' + cstr + ',\n\t ' + sstr + '},' + check = check + '\n\t ' + cstr + ',\n\t ' + sstr + ' },' else: - check = check + ' ' + cstr + ', ' + sstr + '},' + check = check + ' ' + cstr + ', ' + sstr + ' },' else: - check = '\n\t '.join(w.wrap(check + ' ' + cstr + ', ' + sstr + '},')) + check = '\n\t '.join( + w.wrap(check + ' ' + cstr + ', ' + sstr + ' },')) return check skip = False @@ -122,8 +123,8 @@ for line in open(f, 'r'): w = textwrap.TextWrapper(width=80-len(prefix.expandtabs()), break_on_hyphens=False, - replace_whitespace=False, - fix_sentence_endings=True) + replace_whitespace=False, + fix_sentence_endings=True) lastname = None for c in sorted(api_data.methods[config_name].config): name = c.name @@ -190,7 +191,7 @@ def get_default(c): return '(%s)' % (','.join('%s=%s' % (subc.name, get_default(subc)) for subc in sorted(c.subconfig))) elif (c.default or t == 'int') and c.default != 'true': - return str(c.default).replace('"', '\\"') + return str(c.default).replace('"', '\\"') else: return '' @@ -206,10 +207,7 @@ static const WT_CONFIG_CHECK confchk_%(name)s_subconfigs[] = { }; ''' % { 'name' : c.name, - 'check' : '\n\t'.join('"\n\t "'.join( - w.wrap('{ "%s", "%s", %s, NULL },' % - (subc.name, gettype(subc), checkstr(subc)))) - for subc in sorted(c.subconfig)), + 'check' : '\n\t'.join(getconfcheck(subc) for subc in sorted(c.subconfig)), }) def getsubconfigstr(c): @@ -249,9 +247,9 @@ for name in sorted(api_data.methods.keys()): # Build a list of #defines that reference specific slots in the list (the # #defines are used to avoid a list search where we know the correct slot). config_defines +=\ - '#define\tWT_CONFIG_ENTRY_' + name.replace('.', '_') + '\t' * \ - max(1, 6 - (len('WT_CONFIG_ENTRY_' + name) / 8)) + \ - "%2s" % str(slot) + '\n' + '#define\tWT_CONFIG_ENTRY_' + name.replace('.', '_') + '\t' * \ + max(1, 6 - (len('WT_CONFIG_ENTRY_' + name) / 8)) + \ + "%2s" % str(slot) + '\n' # Write the method name and base. tfile.write(''' @@ -319,15 +317,15 @@ compare_srcfile(tmp_file, f) tfile = open(tmp_file, 'w') skip = 0 for line in open('../src/include/config.h', 'r'): - if skip: - if 'configuration section: END' in line: - tfile.write('/*\n' + line) - skip = 0 - else: - tfile.write(line) - if 'configuration section: BEGIN' in line: - skip = 1 - tfile.write(' */\n') - tfile.write(config_defines) + if skip: + if 'configuration section: END' in line: + tfile.write('/*\n' + line) + skip = 0 + else: + tfile.write(line) + if 'configuration section: BEGIN' in line: + skip = 1 + tfile.write(' */\n') + tfile.write(config_defines) tfile.close() compare_srcfile(tmp_file, '../src/include/config.h') diff --git a/dist/api_data.py b/dist/api_data.py index b38dc7a6ad2..d1b7edd26a8 100644 --- a/dist/api_data.py +++ b/dist/api_data.py @@ -596,6 +596,10 @@ methods = { priority of the transaction for resolving conflicts. Transactions with higher values are less likely to abort''', min='-100', max='100'), + Config('sync', '', r''' + whether to sync log records when the transaction commits, + inherited from ::wiredtiger_open \c transaction_sync''', + type='boolean'), ]), 'session.commit_transaction' : Method([]), @@ -748,9 +752,18 @@ methods = { maximum expected number of sessions (including server threads)''', min='1'), - Config('transaction_sync', 'fsync', r''' + Config('transaction_sync', '', r''' how to sync log records when the transaction commits''', - choices=['dsync', 'fsync', 'none']), + type='category', subconfig=[ + Config('enabled', 'false', r''' + whether to sync the log on every commit by default, can + be overridden by the \c sync setting to + WT_SESSION::begin_transaction''', + type='boolean'), + Config('method', 'fsync', r''' + the method used to ensure log records are stable on disk''', + choices=['dsync', 'fsync', 'none']), + ]), Config('use_environment_priv', 'false', r''' use the \c WIREDTIGER_CONFIG and \c WIREDTIGER_HOME environment variables regardless of whether or not the process is running diff --git a/dist/flags.py b/dist/flags.py index 8a8641d2187..3a99022a571 100644 --- a/dist/flags.py +++ b/dist/flags.py @@ -17,17 +17,18 @@ flags = { 'file_types' : [ 'FILE_TYPE_CHECKPOINT', 'FILE_TYPE_DATA', - 'FILE_TYPE_LOG' + 'FILE_TYPE_LOG', ], 'log_scan' : [ 'LOGSCAN_FIRST', 'LOGSCAN_FROM_CKP', 'LOGSCAN_ONE', - 'LOGSCAN_RECOVER' + 'LOGSCAN_RECOVER', ], 'log_write' : [ 'LOG_DSYNC', - 'LOG_FSYNC' + 'LOG_FLUSH', + 'LOG_FSYNC', ], 'page_read' : [ 'READ_CACHE', @@ -43,10 +44,10 @@ flags = { 'rec_write' : [ 'EVICTING', 'SKIP_UPDATE_ERR', - 'SKIP_UPDATE_RESTORE' + 'SKIP_UPDATE_RESTORE', ], 'shared_cache' : [ - 'CACHE_POOL_RUN' + 'CACHE_POOL_RUN', ], 'txn_log_checkpoint' : [ 'TXN_LOG_CKPT_FAIL', @@ -75,7 +76,7 @@ flags = { 'VERB_SPLIT', 'VERB_VERIFY', 'VERB_VERSION', - 'VERB_WRITE' + 'VERB_WRITE', ], ################################################### diff --git a/src/config/config_def.c b/src/config/config_def.c index b411e674d7e..7baacb0bd8f 100644 --- a/src/config/config_def.c +++ b/src/config/config_def.c @@ -3,36 +3,36 @@ #include "wt_internal.h" static const WT_CONFIG_CHECK confchk_colgroup_meta[] = { - { "columns", "list", NULL, NULL}, - { "source", "string", NULL, NULL}, - { "type", "string", NULL, NULL}, + { "columns", "list", NULL, NULL }, + { "source", "string", NULL, NULL }, + { "type", "string", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_connection_async_new_op[] = { - { "append", "boolean", NULL, NULL}, - { "overwrite", "boolean", NULL, NULL}, - { "raw", "boolean", NULL, NULL}, - { "timeout", "int", NULL, NULL}, + { "append", "boolean", NULL, NULL }, + { "overwrite", "boolean", NULL, NULL }, + { "raw", "boolean", NULL, NULL }, + { "timeout", "int", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_connection_close[] = { - { "leak_memory", "boolean", NULL, NULL}, + { "leak_memory", "boolean", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_connection_load_extension[] = { - { "config", "string", NULL, NULL}, - { "entry", "string", NULL, NULL}, - { "terminate", "string", NULL, NULL}, + { "config", "string", NULL, NULL }, + { "entry", "string", NULL, NULL }, + { "terminate", "string", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_connection_open_session[] = { { "isolation", "string", "choices=[\"read-uncommitted\",\"read-committed\",\"snapshot\"]", - NULL}, + NULL }, { NULL, NULL, NULL, NULL } }; @@ -66,97 +66,98 @@ static const WT_CONFIG_CHECK confchk_statistics_log_subconfigs[] = { }; static const WT_CONFIG_CHECK confchk_connection_reconfigure[] = { - { "async", "category", NULL, confchk_async_subconfigs}, - { "cache_size", "int", "min=1MB,max=10TB", NULL}, - { "checkpoint", "category", NULL, confchk_checkpoint_subconfigs} - , - { "error_prefix", "string", NULL, NULL}, - { "eviction_dirty_target", "int", "min=10,max=99", NULL}, - { "eviction_target", "int", "min=10,max=99", NULL}, - { "eviction_trigger", "int", "min=10,max=99", NULL}, - { "eviction_workers", "int", "min=0,max=20", NULL}, + { "async", "category", NULL, confchk_async_subconfigs }, + { "cache_size", "int", "min=1MB,max=10TB", NULL }, + { "checkpoint", "category", NULL, + confchk_checkpoint_subconfigs }, + { "error_prefix", "string", NULL, NULL }, + { "eviction_dirty_target", "int", "min=10,max=99", NULL }, + { "eviction_target", "int", "min=10,max=99", NULL }, + { "eviction_trigger", "int", "min=10,max=99", NULL }, + { "eviction_workers", "int", "min=0,max=20", NULL }, { "shared_cache", "category", NULL, - confchk_shared_cache_subconfigs}, + confchk_shared_cache_subconfigs }, { "statistics", "list", "choices=[\"all\",\"fast\",\"none\",\"clear\"]", - NULL}, + NULL }, { "statistics_log", "category", NULL, - confchk_statistics_log_subconfigs}, + confchk_statistics_log_subconfigs }, { "verbose", "list", "choices=[\"api\",\"block\",\"checkpoint\",\"compact\",\"evict\"" ",\"evictserver\",\"fileops\",\"log\",\"lsm\",\"metadata\"," "\"mutex\",\"overflow\",\"read\",\"readserver\",\"reconcile\"," "\"recovery\",\"salvage\",\"shared_cache\",\"split\",\"verify\"," "\"version\",\"write\"]", - NULL}, + NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_file_meta[] = { - { "allocation_size", "int", "min=512B,max=128MB", NULL}, + { "allocation_size", "int", "min=512B,max=128MB", NULL }, { "block_allocation", "string", "choices=[\"first\",\"best\"]", - NULL}, - { "block_compressor", "string", NULL, NULL}, - { "cache_resident", "boolean", NULL, NULL}, - { "checkpoint", "string", NULL, NULL}, - { "checkpoint_lsn", "string", NULL, NULL}, + NULL }, + { "block_compressor", "string", NULL, NULL }, + { "cache_resident", "boolean", NULL, NULL }, + { "checkpoint", "string", NULL, NULL }, + { "checkpoint_lsn", "string", NULL, NULL }, { "checksum", "string", "choices=[\"on\",\"off\",\"uncompressed\"]", - NULL}, - { "collator", "string", NULL, NULL}, - { "columns", "list", NULL, NULL}, - { "dictionary", "int", "min=0", NULL}, - { "format", "string", "choices=[\"btree\"]", NULL}, - { "huffman_key", "string", NULL, NULL}, - { "huffman_value", "string", NULL, NULL}, - { "id", "string", NULL, NULL}, - { "internal_item_max", "int", "min=0", NULL}, - { "internal_key_truncate", "boolean", NULL, NULL}, - { "internal_page_max", "int", "min=512B,max=512MB", NULL}, - { "key_format", "format", NULL, NULL}, - { "key_gap", "int", "min=0", NULL}, - { "leaf_item_max", "int", "min=0", NULL}, - { "leaf_page_max", "int", "min=512B,max=512MB", NULL}, - { "memory_page_max", "int", "min=512B,max=10TB", NULL}, - { "os_cache_dirty_max", "int", "min=0", NULL}, - { "os_cache_max", "int", "min=0", NULL}, - { "prefix_compression", "boolean", NULL, NULL}, - { "prefix_compression_min", "int", "min=0", NULL}, - { "split_pct", "int", "min=25,max=100", NULL}, - { "value_format", "format", NULL, NULL}, - { "version", "string", NULL, NULL}, + NULL }, + { "collator", "string", NULL, NULL }, + { "columns", "list", NULL, NULL }, + { "dictionary", "int", "min=0", NULL }, + { "format", "string", "choices=[\"btree\"]", NULL }, + { "huffman_key", "string", NULL, NULL }, + { "huffman_value", "string", NULL, NULL }, + { "id", "string", NULL, NULL }, + { "internal_item_max", "int", "min=0", NULL }, + { "internal_key_truncate", "boolean", NULL, NULL }, + { "internal_page_max", "int", "min=512B,max=512MB", NULL }, + { "key_format", "format", NULL, NULL }, + { "key_gap", "int", "min=0", NULL }, + { "leaf_item_max", "int", "min=0", NULL }, + { "leaf_page_max", "int", "min=512B,max=512MB", NULL }, + { "memory_page_max", "int", "min=512B,max=10TB", NULL }, + { "os_cache_dirty_max", "int", "min=0", NULL }, + { "os_cache_max", "int", "min=0", NULL }, + { "prefix_compression", "boolean", NULL, NULL }, + { "prefix_compression_min", "int", "min=0", NULL }, + { "split_pct", "int", "min=25,max=100", NULL }, + { "value_format", "format", NULL, NULL }, + { "version", "string", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_index_meta[] = { - { "columns", "list", NULL, NULL}, - { "key_format", "format", NULL, NULL}, - { "source", "string", NULL, NULL}, - { "type", "string", NULL, NULL}, - { "value_format", "format", NULL, NULL}, + { "columns", "list", NULL, NULL }, + { "key_format", "format", NULL, NULL }, + { "source", "string", NULL, NULL }, + { "type", "string", NULL, NULL }, + { "value_format", "format", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_session_begin_transaction[] = { { "isolation", "string", "choices=[\"read-uncommitted\",\"read-committed\",\"snapshot\"]", - NULL}, - { "name", "string", NULL, NULL}, - { "priority", "int", "min=-100,max=100", NULL}, + NULL }, + { "name", "string", NULL, NULL }, + { "priority", "int", "min=-100,max=100", NULL }, + { "sync", "boolean", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_session_checkpoint[] = { - { "drop", "list", NULL, NULL}, - { "force", "boolean", NULL, NULL}, - { "name", "string", NULL, NULL}, - { "target", "list", NULL, NULL}, + { "drop", "list", NULL, NULL }, + { "force", "boolean", NULL, NULL }, + { "name", "string", NULL, NULL }, + { "target", "list", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_session_compact[] = { - { "timeout", "int", NULL, NULL}, + { "timeout", "int", NULL, NULL }, { NULL, NULL, NULL, NULL } }; @@ -176,92 +177,92 @@ static const WT_CONFIG_CHECK confchk_lsm_subconfigs[] = { }; static const WT_CONFIG_CHECK confchk_session_create[] = { - { "allocation_size", "int", "min=512B,max=128MB", NULL}, + { "allocation_size", "int", "min=512B,max=128MB", NULL }, { "block_allocation", "string", "choices=[\"first\",\"best\"]", - NULL}, - { "block_compressor", "string", NULL, NULL}, - { "cache_resident", "boolean", NULL, NULL}, + NULL }, + { "block_compressor", "string", NULL, NULL }, + { "cache_resident", "boolean", NULL, NULL }, { "checksum", "string", "choices=[\"on\",\"off\",\"uncompressed\"]", - NULL}, - { "colgroups", "list", NULL, NULL}, - { "collator", "string", NULL, NULL}, - { "columns", "list", NULL, NULL}, - { "dictionary", "int", "min=0", NULL}, - { "exclusive", "boolean", NULL, NULL}, - { "format", "string", "choices=[\"btree\"]", NULL}, - { "huffman_key", "string", NULL, NULL}, - { "huffman_value", "string", NULL, NULL}, - { "internal_item_max", "int", "min=0", NULL}, - { "internal_key_truncate", "boolean", NULL, NULL}, - { "internal_page_max", "int", "min=512B,max=512MB", NULL}, - { "key_format", "format", NULL, NULL}, - { "key_gap", "int", "min=0", NULL}, - { "leaf_item_max", "int", "min=0", NULL}, - { "leaf_page_max", "int", "min=512B,max=512MB", NULL}, - { "lsm", "category", NULL, confchk_lsm_subconfigs}, - { "memory_page_max", "int", "min=512B,max=10TB", NULL}, - { "os_cache_dirty_max", "int", "min=0", NULL}, - { "os_cache_max", "int", "min=0", NULL}, - { "prefix_compression", "boolean", NULL, NULL}, - { "prefix_compression_min", "int", "min=0", NULL}, - { "source", "string", NULL, NULL}, - { "split_pct", "int", "min=25,max=100", NULL}, - { "type", "string", NULL, NULL}, - { "value_format", "format", NULL, NULL}, + NULL }, + { "colgroups", "list", NULL, NULL }, + { "collator", "string", NULL, NULL }, + { "columns", "list", NULL, NULL }, + { "dictionary", "int", "min=0", NULL }, + { "exclusive", "boolean", NULL, NULL }, + { "format", "string", "choices=[\"btree\"]", NULL }, + { "huffman_key", "string", NULL, NULL }, + { "huffman_value", "string", NULL, NULL }, + { "internal_item_max", "int", "min=0", NULL }, + { "internal_key_truncate", "boolean", NULL, NULL }, + { "internal_page_max", "int", "min=512B,max=512MB", NULL }, + { "key_format", "format", NULL, NULL }, + { "key_gap", "int", "min=0", NULL }, + { "leaf_item_max", "int", "min=0", NULL }, + { "leaf_page_max", "int", "min=512B,max=512MB", NULL }, + { "lsm", "category", NULL, confchk_lsm_subconfigs }, + { "memory_page_max", "int", "min=512B,max=10TB", NULL }, + { "os_cache_dirty_max", "int", "min=0", NULL }, + { "os_cache_max", "int", "min=0", NULL }, + { "prefix_compression", "boolean", NULL, NULL }, + { "prefix_compression_min", "int", "min=0", NULL }, + { "source", "string", NULL, NULL }, + { "split_pct", "int", "min=25,max=100", NULL }, + { "type", "string", NULL, NULL }, + { "value_format", "format", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_session_drop[] = { - { "force", "boolean", NULL, NULL}, - { "remove_files", "boolean", NULL, NULL}, + { "force", "boolean", NULL, NULL }, + { "remove_files", "boolean", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_session_open_cursor[] = { - { "append", "boolean", NULL, NULL}, - { "bulk", "string", NULL, NULL}, - { "checkpoint", "string", NULL, NULL}, + { "append", "boolean", NULL, NULL }, + { "bulk", "string", NULL, NULL }, + { "checkpoint", "string", NULL, NULL }, { "dump", "string", "choices=[\"hex\",\"json\",\"print\"]", - NULL}, - { "next_random", "boolean", NULL, NULL}, - { "overwrite", "boolean", NULL, NULL}, - { "raw", "boolean", NULL, NULL}, - { "readonly", "boolean", NULL, NULL}, + NULL }, + { "next_random", "boolean", NULL, NULL }, + { "overwrite", "boolean", NULL, NULL }, + { "raw", "boolean", NULL, NULL }, + { "readonly", "boolean", NULL, NULL }, { "statistics", "list", "choices=[\"all\",\"fast\",\"clear\"]", - NULL}, - { "target", "list", NULL, NULL}, + NULL }, + { "target", "list", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_session_reconfigure[] = { { "isolation", "string", "choices=[\"read-uncommitted\",\"read-committed\",\"snapshot\"]", - NULL}, + NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_session_salvage[] = { - { "force", "boolean", NULL, NULL}, + { "force", "boolean", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_session_verify[] = { - { "dump_address", "boolean", NULL, NULL}, - { "dump_blocks", "boolean", NULL, NULL}, - { "dump_offsets", "list", NULL, NULL}, - { "dump_pages", "boolean", NULL, NULL}, + { "dump_address", "boolean", NULL, NULL }, + { "dump_blocks", "boolean", NULL, NULL }, + { "dump_offsets", "list", NULL, NULL }, + { "dump_pages", "boolean", NULL, NULL }, { NULL, NULL, NULL, NULL } }; static const WT_CONFIG_CHECK confchk_table_meta[] = { - { "colgroups", "list", NULL, NULL}, - { "columns", "list", NULL, NULL}, - { "key_format", "format", NULL, NULL}, - { "value_format", "format", NULL, NULL}, + { "colgroups", "list", NULL, NULL }, + { "columns", "list", NULL, NULL }, + { "key_format", "format", NULL, NULL }, + { "value_format", "format", NULL, NULL }, { NULL, NULL, NULL, NULL } }; @@ -273,48 +274,55 @@ static const WT_CONFIG_CHECK confchk_log_subconfigs[] = { { NULL, NULL, NULL, NULL } }; +static const WT_CONFIG_CHECK confchk_transaction_sync_subconfigs[] = { + { "enabled", "boolean", NULL, NULL }, + { "method", "string", + "choices=[\"dsync\",\"fsync\",\"none\"]", + NULL }, + { NULL, NULL, NULL, NULL } +}; + static const WT_CONFIG_CHECK confchk_wiredtiger_open[] = { - { "async", "category", NULL, confchk_async_subconfigs}, - { "buffer_alignment", "int", "min=-1,max=1MB", NULL}, - { "cache_size", "int", "min=1MB,max=10TB", NULL}, - { "checkpoint", "category", NULL, confchk_checkpoint_subconfigs} - , - { "checkpoint_sync", "boolean", NULL, NULL}, - { "create", "boolean", NULL, NULL}, + { "async", "category", NULL, confchk_async_subconfigs }, + { "buffer_alignment", "int", "min=-1,max=1MB", NULL }, + { "cache_size", "int", "min=1MB,max=10TB", NULL }, + { "checkpoint", "category", NULL, + confchk_checkpoint_subconfigs }, + { "checkpoint_sync", "boolean", NULL, NULL }, + { "create", "boolean", NULL, NULL }, { "direct_io", "list", "choices=[\"checkpoint\",\"data\",\"log\"]", - NULL}, - { "error_prefix", "string", NULL, NULL}, - { "eviction_dirty_target", "int", "min=10,max=99", NULL}, - { "eviction_target", "int", "min=10,max=99", NULL}, - { "eviction_trigger", "int", "min=10,max=99", NULL}, - { "eviction_workers", "int", "min=0,max=20", NULL}, - { "extensions", "list", NULL, NULL}, - { "file_extend", "list", "choices=[\"data\",\"log\"]", NULL}, - { "hazard_max", "int", "min=15", NULL}, - { "log", "category", NULL, confchk_log_subconfigs}, - { "lsm_merge", "boolean", NULL, NULL}, - { "mmap", "boolean", NULL, NULL}, - { "multiprocess", "boolean", NULL, NULL}, - { "session_max", "int", "min=1", NULL}, + NULL }, + { "error_prefix", "string", NULL, NULL }, + { "eviction_dirty_target", "int", "min=10,max=99", NULL }, + { "eviction_target", "int", "min=10,max=99", NULL }, + { "eviction_trigger", "int", "min=10,max=99", NULL }, + { "eviction_workers", "int", "min=0,max=20", NULL }, + { "extensions", "list", NULL, NULL }, + { "file_extend", "list", "choices=[\"data\",\"log\"]", NULL }, + { "hazard_max", "int", "min=15", NULL }, + { "log", "category", NULL, confchk_log_subconfigs }, + { "lsm_merge", "boolean", NULL, NULL }, + { "mmap", "boolean", NULL, NULL }, + { "multiprocess", "boolean", NULL, NULL }, + { "session_max", "int", "min=1", NULL }, { "shared_cache", "category", NULL, - confchk_shared_cache_subconfigs}, + confchk_shared_cache_subconfigs }, { "statistics", "list", "choices=[\"all\",\"fast\",\"none\",\"clear\"]", - NULL}, + NULL }, { "statistics_log", "category", NULL, - confchk_statistics_log_subconfigs}, - { "transaction_sync", "string", - "choices=[\"dsync\",\"fsync\",\"none\"]", - NULL}, - { "use_environment_priv", "boolean", NULL, NULL}, + confchk_statistics_log_subconfigs }, + { "transaction_sync", "category", NULL, + confchk_transaction_sync_subconfigs }, + { "use_environment_priv", "boolean", NULL, NULL }, { "verbose", "list", "choices=[\"api\",\"block\",\"checkpoint\",\"compact\",\"evict\"" ",\"evictserver\",\"fileops\",\"log\",\"lsm\",\"metadata\"," "\"mutex\",\"overflow\",\"read\",\"readserver\",\"reconcile\"," "\"recovery\",\"salvage\",\"shared_cache\",\"split\",\"verify\"," "\"version\",\"write\"]", - NULL}, + NULL }, { NULL, NULL, NULL, NULL } }; @@ -387,7 +395,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { confchk_index_meta }, { "session.begin_transaction", - "isolation=,name=,priority=0", + "isolation=,name=,priority=0,sync=", confchk_session_begin_transaction }, { "session.checkpoint", @@ -475,8 +483,8 @@ static const WT_CONFIG_ENTRY config_entries[] = { "mmap=,multiprocess=0,session_max=100,shared_cache=(chunk=10MB," "name=,reserve=0,size=500MB),statistics=none," "statistics_log=(path=\"WiredTigerStat.%d.%H\",sources=," - "timestamp=\"%b %d %H:%M:%S\",wait=0),transaction_sync=fsync," - "use_environment_priv=0,verbose=", + "timestamp=\"%b %d %H:%M:%S\",wait=0),transaction_sync=(enabled=0" + ",method=fsync),use_environment_priv=0,verbose=", confchk_wiredtiger_open }, { NULL, NULL, NULL } diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c index be35a99d8aa..a9085f15029 100644 --- a/src/conn/conn_log.c +++ b/src/conn/conn_log.c @@ -8,24 +8,43 @@ #include "wt_internal.h" /* + * __logmgr_sync_cfg -- + * Interpret the transaction_sync config. + */ +static int +__logmgr_sync_cfg(WT_SESSION_IMPL *session, const char **cfg) +{ + WT_CONFIG_ITEM cval; + WT_CONNECTION_IMPL *conn; + + conn = S2C(session); + + WT_RET( + __wt_config_gets(session, cfg, "transaction_sync.enabled", &cval)); + if (cval.val) + FLD_SET(conn->txn_logsync, WT_LOG_FLUSH); + else + FLD_CLR(conn->txn_logsync, WT_LOG_FLUSH); + + WT_RET( + __wt_config_gets(session, cfg, "transaction_sync.method", &cval)); + FLD_CLR(conn->txn_logsync, WT_LOG_DSYNC | WT_LOG_FSYNC); + if (WT_STRING_MATCH("dsync", cval.str, cval.len)) + FLD_SET(conn->txn_logsync, WT_LOG_DSYNC); + else if (WT_STRING_MATCH("fsync", cval.str, cval.len)) + FLD_SET(conn->txn_logsync, WT_LOG_FSYNC); + return (0); +} + +/* * __logmgr_config -- * Parse and setup the logging server options. */ static int __logmgr_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) { - static const struct { - const char *name; - uint32_t flag; - } *st, sync_types[] = { - { "dsync", WT_LOG_DSYNC}, - { "fsync", WT_LOG_FSYNC}, - { "none", 0 }, - { NULL, 0 } - }; - WT_CONFIG_ITEM cval, sval; + WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; - WT_DECL_RET; conn = S2C(session); @@ -47,19 +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)); - conn->txn_logsync = WT_LOG_DSYNC; - WT_RET(__wt_config_gets(session, cfg, "transaction_sync", &cval)); - for (st = sync_types; st->name != NULL; st++) { - ret = __wt_config_subgets(session, &cval, st->name, &sval); - if (ret == 0) { - if (sval.val) - conn->txn_logsync = st->flag; - } else if (ret != WT_NOTFOUND) - goto err; - } - ret = 0; -err: - return (ret); + WT_RET(__logmgr_sync_cfg(session, cfg)); + return (0); } /* diff --git a/src/docs/upgrading.dox b/src/docs/upgrading.dox index 908da65188d..c5a24279d4c 100644 --- a/src/docs/upgrading.dox +++ b/src/docs/upgrading.dox @@ -33,6 +33,17 @@ configured \c os_cache_dirty_max, causing additional system calls that slowed some workloads. Applications that benefit from this setting should set it explicitly in WT_SESSION::create. </dd> + +<dt>\c transaction_sync setting change</dt> +<dd> +In the 2.2.1 release of WiredTiger the ::wiredtiger_open \c transaction_sync +configuration setting has changed from a string value to a structure with two +fields: \c method, which corresponds to the previous value (\c dsync, \c fsync +or \c none), and \c enabled, which determines whether there is a sync on +every transaction commit by default. Applications can enable or disable sync +for a specific transaction with the \c sync setting to +WT_SESSION::begin_transaction. +</dd> </dl> @section version_220 Upgrading to Version 2.2.0 diff --git a/src/include/flags.h b/src/include/flags.h index 5f23c9b38db..80f2a1079e9 100644 --- a/src/include/flags.h +++ b/src/include/flags.h @@ -23,7 +23,8 @@ #define WT_LOGSCAN_FROM_CKP 0x00000004 #define WT_LOGSCAN_ONE 0x00000002 #define WT_LOGSCAN_RECOVER 0x00000001 -#define WT_LOG_DSYNC 0x00000002 +#define WT_LOG_DSYNC 0x00000004 +#define WT_LOG_FLUSH 0x00000002 #define WT_LOG_FSYNC 0x00000001 #define WT_READ_CACHE 0x00000100 #define WT_READ_COMPACT 0x00000080 diff --git a/src/include/txn.h b/src/include/txn.h index 99851d4eca7..bbd24362c16 100644 --- a/src/include/txn.h +++ b/src/include/txn.h @@ -108,6 +108,7 @@ struct __wt_txn { uint64_t snap_min, snap_max; uint64_t *snapshot; uint32_t snapshot_count; + uint32_t txn_logsync; /* Log sync configuration */ /* Array of modifications by this transaction. */ WT_TXN_OP *mod; diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in index 4dd77db15e9..e1a400913ff 100644 --- a/src/include/wiredtiger.in +++ b/src/include/wiredtiger.in @@ -1400,6 +1400,9 @@ struct __wt_session { * @config{priority, priority of the transaction for resolving * conflicts. Transactions with higher values are less likely to * abort., an integer between -100 and 100; default \c 0.} + * @config{sync, whether to sync log records when the transaction + * commits\, inherited from ::wiredtiger_open \c transaction_sync., a + * boolean flag; default empty.} * @configend * @errors */ @@ -1986,9 +1989,15 @@ struct __wt_connection { * between each write of the log records., an integer between 0 and 100000; * default \c 0.} * @config{ ),,} - * @config{transaction_sync, how to sync log records when the transaction - * commits., a string\, chosen from the following options: \c "dsync"\, \c - * "fsync"\, \c "none"; default \c fsync.} + * @config{transaction_sync = (, how to sync log records when the transaction + * commits., a set of related configuration options defined below.} + * @config{ enabled, whether to sync the log on every + * commit by default\, can be overridden by the \c sync setting to + * WT_SESSION::begin_transaction., a boolean flag; default \c false.} + * @config{ method, the method used to ensure log records + * are stable on disk., a string\, chosen from the following options: \c + * "dsync"\, \c "fsync"\, \c "none"; default \c fsync.} + * @config{ ),,} * @config{use_environment_priv, use the \c WIREDTIGER_CONFIG and \c * WIREDTIGER_HOME environment variables regardless of whether or not the * process is running with special privileges. See @ref home for more diff --git a/src/txn/txn.c b/src/txn/txn.c index ab1a77fb5e5..2edf45c34cc 100644 --- a/src/txn/txn.c +++ b/src/txn/txn.c @@ -252,6 +252,16 @@ __wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[]) WT_STRING_MATCH("read-committed", cval.str, cval.len) ? TXN_ISO_READ_COMMITTED : TXN_ISO_READ_UNCOMMITTED; + /* + * The default sync setting is inherited from the connection, but can + * be overridden by an explicit "sync" setting for this transaction. + */ + txn->txn_logsync = S2C(session)->txn_logsync; + WT_RET(__wt_config_gets_def(session, cfg, "sync", + FLD_ISSET(txn->txn_logsync, WT_LOG_FLUSH), &cval)); + if (!cval.val) + txn->txn_logsync = 0; + F_SET(txn, TXN_RUNNING); if (txn->isolation == TXN_ISO_SNAPSHOT) __wt_txn_refresh(session, WT_TXN_NONE, 1); diff --git a/src/txn/txn_log.c b/src/txn/txn_log.c index 01a49e9c583..3ad36fa118f 100644 --- a/src/txn/txn_log.c +++ b/src/txn/txn_log.c @@ -189,7 +189,7 @@ __wt_txn_log_commit(WT_SESSION_IMPL *session, const char *cfg[]) /* Write updates to the log. */ return (__wt_log_write(session, - txn->logrec, NULL, S2C(session)->txn_logsync)); + txn->logrec, NULL, txn->txn_logsync)); } /* diff --git a/test/suite/test_txn02.py b/test/suite/test_txn02.py index c3e8e51d8df..3eb35de8691 100644 --- a/test/suite/test_txn02.py +++ b/test/suite/test_txn02.py @@ -41,7 +41,12 @@ class test_txn02(wttest.WiredTigerTestCase, suite_subprocess): uri = 'table:' + tablename archive_list = ['true', 'false'] conn_list = ['reopen', 'stay_open'] - sync_list = ['dsync', 'fsync', 'none'] + sync_list = [ + '(method=dsync,enabled)', + '(method=fsync,enabled)', + '(method=none,enabled)', + '(enabled=false)' + ] types = [ ('row', dict(tabletype='row', @@ -210,7 +215,8 @@ class test_txn02(wttest.WiredTigerTestCase, suite_subprocess): self.reopen_conn() c = self.session.open_cursor(self.uri, None, 'overwrite') - self.session.begin_transaction() + self.session.begin_transaction( + (self.scenario_number % 2) and 'sync' or None) # Test multiple operations per transaction by always # doing the same operation on key k + 1. k1 = k + 1 diff --git a/test/suite/test_txn04.py b/test/suite/test_txn04.py index 66f41903592..7e8b448856b 100644 --- a/test/suite/test_txn04.py +++ b/test/suite/test_txn04.py @@ -39,7 +39,12 @@ class test_txn04(wttest.WiredTigerTestCase, suite_subprocess): logmax = "100K" tablename = 'test_txn04' uri = 'table:' + tablename - sync_list = ['dsync', 'fsync', 'none'] + sync_list = [ + '(method=dsync,enabled)', + '(method=fsync,enabled)', + '(method=none,enabled)', + '(enabled=false)' + ] types = [ ('row', dict(tabletype='row', diff --git a/test/suite/test_txn05.py b/test/suite/test_txn05.py index 37f240bec73..83218dba27b 100644 --- a/test/suite/test_txn05.py +++ b/test/suite/test_txn05.py @@ -40,7 +40,12 @@ class test_txn05(wttest.WiredTigerTestCase, suite_subprocess): tablename = 'test_txn05' uri = 'table:' + tablename archive_list = ['true', 'false'] - sync_list = ['dsync', 'fsync', 'none'] + sync_list = [ + '(method=dsync,enabled)', + '(method=fsync,enabled)', + '(method=none,enabled)', + '(enabled=false)' + ] types = [ ('row', dict(tabletype='row', |