summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2022-10-10 09:24:46 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-09 22:57:27 +0000
commit1043b0150e33ec5c27d6f410fe074e22efc9e3e7 (patch)
treec251e2594e42f9f3827541f4c6b4f4f231dce778 /src/third_party/wiredtiger/test
parent96c58d4b1e9dbd18be495a7788909e15f40970bd (diff)
downloadmongo-1043b0150e33ec5c27d6f410fe074e22efc9e3e7.tar.gz
Import wiredtiger: 34370d2091b601498ecf85fad57bcc892cc9bff9 from branch mongodb-master
ref: f3627162fc..34370d2091 for: 6.2.0-rc0 WT-9903 Create a debug mode for __wt_realloc stress testing using malloc (#8332)
Diffstat (limited to 'src/third_party/wiredtiger/test')
-rw-r--r--src/third_party/wiredtiger/test/format/config.h148
-rwxr-xr-xsrc/third_party/wiredtiger/test/format/config.sh4
-rw-r--r--src/third_party/wiredtiger/test/format/config_def.c6
-rw-r--r--src/third_party/wiredtiger/test/format/wts.c11
-rw-r--r--src/third_party/wiredtiger/test/suite/test_debug_mode10.py58
5 files changed, 154 insertions, 73 deletions
diff --git a/src/third_party/wiredtiger/test/format/config.h b/src/third_party/wiredtiger/test/format/config.h
index 17ff84d15bd..38b7adc3aac 100644
--- a/src/third_party/wiredtiger/test/format/config.h
+++ b/src/third_party/wiredtiger/test/format/config.h
@@ -61,77 +61,79 @@ typedef struct {
#define V_GLOBAL_CHECKPOINT 29
#define V_GLOBAL_CHECKPOINT_LOG_SIZE 30
#define V_GLOBAL_CHECKPOINT_WAIT 31
-#define V_TABLE_DISK_CHECKSUM 32
-#define V_GLOBAL_DISK_DATA_EXTEND 33
-#define V_GLOBAL_DISK_DIRECT_IO 34
-#define V_GLOBAL_DISK_ENCRYPTION 35
-#define V_TABLE_DISK_FIRSTFIT 36
-#define V_GLOBAL_DISK_MMAP 37
-#define V_GLOBAL_DISK_MMAP_ALL 38
-#define V_GLOBAL_FORMAT_ABORT 39
-#define V_GLOBAL_FORMAT_INDEPENDENT_THREAD_RNG 40
-#define V_GLOBAL_FORMAT_MAJOR_TIMEOUT 41
-#define V_GLOBAL_IMPORT 42
-#define V_GLOBAL_LOGGING 43
-#define V_GLOBAL_LOGGING_COMPRESSION 44
-#define V_GLOBAL_LOGGING_FILE_MAX 45
-#define V_GLOBAL_LOGGING_PREALLOC 46
-#define V_GLOBAL_LOGGING_REMOVE 47
-#define V_TABLE_LSM_AUTO_THROTTLE 48
-#define V_TABLE_LSM_BLOOM 49
-#define V_TABLE_LSM_BLOOM_BIT_COUNT 50
-#define V_TABLE_LSM_BLOOM_HASH_COUNT 51
-#define V_TABLE_LSM_BLOOM_OLDEST 52
-#define V_TABLE_LSM_CHUNK_SIZE 53
-#define V_TABLE_LSM_MERGE_MAX 54
-#define V_GLOBAL_LSM_WORKER_THREADS 55
-#define V_GLOBAL_OPS_ALTER 56
-#define V_GLOBAL_OPS_COMPACTION 57
-#define V_GLOBAL_OPS_HS_CURSOR 58
-#define V_TABLE_OPS_PCT_DELETE 59
-#define V_TABLE_OPS_PCT_INSERT 60
-#define V_TABLE_OPS_PCT_MODIFY 61
-#define V_TABLE_OPS_PCT_READ 62
-#define V_TABLE_OPS_PCT_WRITE 63
-#define V_GLOBAL_OPS_BOUND_CURSOR 64
-#define V_GLOBAL_OPS_PREPARE 65
-#define V_GLOBAL_OPS_RANDOM_CURSOR 66
-#define V_GLOBAL_OPS_SALVAGE 67
-#define V_TABLE_OPS_TRUNCATE 68
-#define V_GLOBAL_OPS_VERIFY 69
-#define V_GLOBAL_QUIET 70
-#define V_GLOBAL_RUNS_IN_MEMORY 71
-#define V_GLOBAL_RUNS_OPS 72
-#define V_TABLE_RUNS_MIRROR 73
-#define V_TABLE_RUNS_ROWS 74
-#define V_TABLE_RUNS_SOURCE 75
-#define V_GLOBAL_RUNS_TABLES 76
-#define V_GLOBAL_RUNS_THREADS 77
-#define V_GLOBAL_RUNS_TIMER 78
-#define V_TABLE_RUNS_TYPE 79
-#define V_GLOBAL_RUNS_VERIFY_FAILURE_DUMP 80
-#define V_GLOBAL_STATISTICS_SERVER 81
-#define V_GLOBAL_STRESS_AGGRESSIVE_SWEEP 82
-#define V_GLOBAL_STRESS_CHECKPOINT 83
-#define V_GLOBAL_STRESS_CHECKPOINT_EVICT_PAGE 84
-#define V_GLOBAL_STRESS_CHECKPOINT_PREPARE 85
-#define V_GLOBAL_STRESS_EVICT_REPOSITION 86
-#define V_GLOBAL_STRESS_FAILPOINT_EVICTION_FAIL_AFTER_RECONCILIATION 87
-#define V_GLOBAL_STRESS_FAILPOINT_HS_DELETE_KEY_FROM_TS 88
-#define V_GLOBAL_STRESS_HS_CHECKPOINT_DELAY 89
-#define V_GLOBAL_STRESS_HS_SEARCH 90
-#define V_GLOBAL_STRESS_HS_SWEEP 91
-#define V_GLOBAL_STRESS_SPLIT_1 92
-#define V_GLOBAL_STRESS_SPLIT_2 93
-#define V_GLOBAL_STRESS_SPLIT_3 94
-#define V_GLOBAL_STRESS_SPLIT_4 95
-#define V_GLOBAL_STRESS_SPLIT_5 96
-#define V_GLOBAL_STRESS_SPLIT_6 97
-#define V_GLOBAL_STRESS_SPLIT_7 98
-#define V_GLOBAL_TRANSACTION_IMPLICIT 99
-#define V_GLOBAL_TRANSACTION_TIMESTAMPS 100
-#define V_GLOBAL_WIREDTIGER_CONFIG 101
-#define V_GLOBAL_WIREDTIGER_RWLOCK 102
-#define V_GLOBAL_WIREDTIGER_LEAK_MEMORY 103
+#define V_GLOBAL_DEBUG_REALLOC_EXACT 32
+#define V_GLOBAL_DEBUG_REALLOC_MALLOC 33
+#define V_TABLE_DISK_CHECKSUM 34
+#define V_GLOBAL_DISK_DATA_EXTEND 35
+#define V_GLOBAL_DISK_DIRECT_IO 36
+#define V_GLOBAL_DISK_ENCRYPTION 37
+#define V_TABLE_DISK_FIRSTFIT 38
+#define V_GLOBAL_DISK_MMAP 39
+#define V_GLOBAL_DISK_MMAP_ALL 40
+#define V_GLOBAL_FORMAT_ABORT 41
+#define V_GLOBAL_FORMAT_INDEPENDENT_THREAD_RNG 42
+#define V_GLOBAL_FORMAT_MAJOR_TIMEOUT 43
+#define V_GLOBAL_IMPORT 44
+#define V_GLOBAL_LOGGING 45
+#define V_GLOBAL_LOGGING_COMPRESSION 46
+#define V_GLOBAL_LOGGING_FILE_MAX 47
+#define V_GLOBAL_LOGGING_PREALLOC 48
+#define V_GLOBAL_LOGGING_REMOVE 49
+#define V_TABLE_LSM_AUTO_THROTTLE 50
+#define V_TABLE_LSM_BLOOM 51
+#define V_TABLE_LSM_BLOOM_BIT_COUNT 52
+#define V_TABLE_LSM_BLOOM_HASH_COUNT 53
+#define V_TABLE_LSM_BLOOM_OLDEST 54
+#define V_TABLE_LSM_CHUNK_SIZE 55
+#define V_TABLE_LSM_MERGE_MAX 56
+#define V_GLOBAL_LSM_WORKER_THREADS 57
+#define V_GLOBAL_OPS_ALTER 58
+#define V_GLOBAL_OPS_COMPACTION 59
+#define V_GLOBAL_OPS_HS_CURSOR 60
+#define V_TABLE_OPS_PCT_DELETE 61
+#define V_TABLE_OPS_PCT_INSERT 62
+#define V_TABLE_OPS_PCT_MODIFY 63
+#define V_TABLE_OPS_PCT_READ 64
+#define V_TABLE_OPS_PCT_WRITE 65
+#define V_GLOBAL_OPS_BOUND_CURSOR 66
+#define V_GLOBAL_OPS_PREPARE 67
+#define V_GLOBAL_OPS_RANDOM_CURSOR 68
+#define V_GLOBAL_OPS_SALVAGE 69
+#define V_TABLE_OPS_TRUNCATE 70
+#define V_GLOBAL_OPS_VERIFY 71
+#define V_GLOBAL_QUIET 72
+#define V_GLOBAL_RUNS_IN_MEMORY 73
+#define V_GLOBAL_RUNS_OPS 74
+#define V_TABLE_RUNS_MIRROR 75
+#define V_TABLE_RUNS_ROWS 76
+#define V_TABLE_RUNS_SOURCE 77
+#define V_GLOBAL_RUNS_TABLES 78
+#define V_GLOBAL_RUNS_THREADS 79
+#define V_GLOBAL_RUNS_TIMER 80
+#define V_TABLE_RUNS_TYPE 81
+#define V_GLOBAL_RUNS_VERIFY_FAILURE_DUMP 82
+#define V_GLOBAL_STATISTICS_SERVER 83
+#define V_GLOBAL_STRESS_AGGRESSIVE_SWEEP 84
+#define V_GLOBAL_STRESS_CHECKPOINT 85
+#define V_GLOBAL_STRESS_CHECKPOINT_EVICT_PAGE 86
+#define V_GLOBAL_STRESS_CHECKPOINT_PREPARE 87
+#define V_GLOBAL_STRESS_EVICT_REPOSITION 88
+#define V_GLOBAL_STRESS_FAILPOINT_EVICTION_FAIL_AFTER_RECONCILIATION 89
+#define V_GLOBAL_STRESS_FAILPOINT_HS_DELETE_KEY_FROM_TS 90
+#define V_GLOBAL_STRESS_HS_CHECKPOINT_DELAY 91
+#define V_GLOBAL_STRESS_HS_SEARCH 92
+#define V_GLOBAL_STRESS_HS_SWEEP 93
+#define V_GLOBAL_STRESS_SPLIT_1 94
+#define V_GLOBAL_STRESS_SPLIT_2 95
+#define V_GLOBAL_STRESS_SPLIT_3 96
+#define V_GLOBAL_STRESS_SPLIT_4 97
+#define V_GLOBAL_STRESS_SPLIT_5 98
+#define V_GLOBAL_STRESS_SPLIT_6 99
+#define V_GLOBAL_STRESS_SPLIT_7 100
+#define V_GLOBAL_TRANSACTION_IMPLICIT 101
+#define V_GLOBAL_TRANSACTION_TIMESTAMPS 102
+#define V_GLOBAL_WIREDTIGER_CONFIG 103
+#define V_GLOBAL_WIREDTIGER_RWLOCK 104
+#define V_GLOBAL_WIREDTIGER_LEAK_MEMORY 105
-#define V_ELEMENT_COUNT 104
+#define V_ELEMENT_COUNT 106
diff --git a/src/third_party/wiredtiger/test/format/config.sh b/src/third_party/wiredtiger/test/format/config.sh
index a79144512a8..4d6622a9060 100755
--- a/src/third_party/wiredtiger/test/format/config.sh
+++ b/src/third_party/wiredtiger/test/format/config.sh
@@ -135,6 +135,10 @@ CONFIG configuration_list[] = {
{"checkpoint.wait", "seconds to wait if wiredtiger checkpoints configured", 0x0, 5, 100, 3600}
+{"debug.realloc_exact", "reallocation of memory will only provide the exact amount requested", C_BOOL, 0, 0, 0}
+
+{"debug.realloc_malloc", "every realloc call will force a new memory allocation by using malloc", C_BOOL, 5, 0, 0}
+
{"disk.checksum", "checksum type (on | off | uncompressed | unencrypted)", C_IGNORE | C_STRING | C_TABLE, 0, 0, 0}
{"disk.data_extend", "configure data file extension", C_BOOL, 5, 0, 0}
diff --git a/src/third_party/wiredtiger/test/format/config_def.c b/src/third_party/wiredtiger/test/format/config_def.c
index 2d94c4538fd..539ba902299 100644
--- a/src/third_party/wiredtiger/test/format/config_def.c
+++ b/src/third_party/wiredtiger/test/format/config_def.c
@@ -99,6 +99,12 @@ CONFIG configuration_list[] = {
{"checkpoint.wait", "seconds to wait if wiredtiger checkpoints configured",
0x0, 5, 100, 3600, V_GLOBAL_CHECKPOINT_WAIT},
+ {"debug.realloc_exact", "reallocation of memory will only provide the exact amount requested",
+ C_BOOL, 0, 0, 0, V_GLOBAL_DEBUG_REALLOC_EXACT},
+
+ {"debug.realloc_malloc", "every realloc call will force a new memory allocation by using malloc",
+ C_BOOL, 5, 0, 0, V_GLOBAL_DEBUG_REALLOC_MALLOC},
+
{"disk.checksum", "checksum type (on | off | uncompressed | unencrypted)",
C_IGNORE | C_STRING | C_TABLE, 0, 0, 0, V_TABLE_DISK_CHECKSUM},
diff --git a/src/third_party/wiredtiger/test/format/wts.c b/src/third_party/wiredtiger/test/format/wts.c
index ec2e53eccbb..27ca5e0ca3b 100644
--- a/src/third_party/wiredtiger/test/format/wts.c
+++ b/src/third_party/wiredtiger/test/format/wts.c
@@ -273,6 +273,17 @@ create_database(const char *home, WT_CONNECTION **connp)
if (GV(DISK_DATA_EXTEND))
CONFIG_APPEND(p, ",file_extend=(data=8MB)");
+ if (GV(DEBUG_REALLOC_EXACT))
+ CONFIG_APPEND(p, ",debug_mode=(realloc_exact=true)");
+
+ /* Configure realloc malloc debug mode. */
+ if (GV(DEBUG_REALLOC_MALLOC)) {
+ if (mmrand(NULL, 0, 1) == 1)
+ CONFIG_APPEND(p, ",debug_mode=(realloc_exact=true,realloc_malloc=true)");
+ else
+ CONFIG_APPEND(p, ",debug_mode=(realloc_malloc=true)");
+ }
+
/*
* Run the statistics server and/or maintain statistics in the engine. Sometimes specify a set
* of sources just to exercise that code.
diff --git a/src/third_party/wiredtiger/test/suite/test_debug_mode10.py b/src/third_party/wiredtiger/test/suite/test_debug_mode10.py
new file mode 100644
index 00000000000..4c34aa41816
--- /dev/null
+++ b/src/third_party/wiredtiger/test/suite/test_debug_mode10.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# Public Domain 2014-present MongoDB, Inc.
+# Public Domain 2008-2014 WiredTiger, Inc.
+#
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+import wttest
+
+# test_debug_mode10.py
+# Test the debug mode settings. Test realloc_malloc use.
+class test_debug_mode10(wttest.WiredTigerTestCase):
+ conn_config = 'debug_mode=(realloc_malloc=true)'
+ uri = 'file:test_debug_mode10'
+
+ # Insert some data to ensure setting/unsetting the flag does not
+ # break existing functionality. Also call checkpoint because it
+ # causes the realloc function to be called numerous times.
+ def insert_data(self):
+ self.session.create(self.uri, 'key_format=s,value_format=s')
+ self.cursor = self.session.open_cursor(self.uri, None)
+ self.cursor['key'] = 'value'
+ self.cursor.close()
+ self.session.checkpoint()
+
+ # Make flag works when set.
+ def test_realloc_exact(self):
+ self.insert_data()
+
+ # Make sure the flag can be 'turned off' as well.
+ def test_realloc_exact_off(self):
+ conn_reconfig = 'debug_mode=(realloc_malloc=false)'
+ self.conn.reconfigure(conn_reconfig)
+ self.insert_data()
+
+if __name__ == '__main__':
+ wttest.run()