summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/csuite/wt2719_reconfig/main.c
blob: 1ff7b10e1c61fb67d6a8bce97464c9a8a6e363d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*-
 * Public Domain 2014-2016 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.
 */
#include "test_util.h"

/*
 * JIRA ticket reference: WT-2719
 * Test case description: Fuzz testing for WiredTiger reconfiguration.
 */

void (*custom_die)(void) = NULL;

static const char *list[] = {
	",async=(enabled=0)",
	",async=(enabled=1)",
	",async=(ops_max=2048)",
	",async=(ops_max=2348)",
	",async=(ops_max=1790)",
	",async=(threads=10)",
	",async=(threads=7)",
	",async=(threads=17)",

	",cache_overhead=13",
	",cache_overhead=27",
	",cache_overhead=8",

	",cache_size=75MB",
	",cache_size=214MB",
	",cache_size=37MB",

	",checkpoint=(log_size=104857600)",	/* 100MB */
	",checkpoint=(log_size=1073741824)",	/* 1GB */
	",checkpoint=(log_size=2)",
	",checkpoint=(log_size=0)",
	",checkpoint=(wait=100)",
	",checkpoint=(wait=10000)",
	",checkpoint=(wait=2)",
	",checkpoint=(wait=0)",

	",error_prefix=\"prefix\"",

	",eviction=(threads_min=7,threads_max=10)",
	",eviction=(threads_min=17,threads_max=18)",
	",eviction=(threads_min=3,threads_max=7)",
	",eviction=(threads_max=12,threads_min=10)",
	",eviction=(threads_max=18,threads_min=16)",
	",eviction=(threads_max=10,threads_min=9)",

	",eviction_dirty_target=45",
	",eviction_dirty_target=87",
	",eviction_dirty_target=8",

	",eviction_dirty_trigger=37",
	",eviction_dirty_trigger=98",
	",eviction_dirty_trigger=7",

	",eviction_target=22",
	",eviction_target=84",
	",eviction_target=30",

	",eviction_trigger=75",
	",eviction_trigger=95",
	",eviction_trigger=66",

	",file_manager=(close_handle_minimum=200)",
	",file_manager=(close_handle_minimum=137)",
	",file_manager=(close_handle_minimum=226)",
	",file_manager=(close_idle_time=10000)",
	",file_manager=(close_idle_time=12000)",
	",file_manager=(close_idle_time=7)",
	",file_manager=(close_idle_time=0)",
	",file_manager=(close_scan_interval=50000)",
	",file_manager=(close_scan_interval=59000)",
	",file_manager=(close_scan_interval=3)",

	",log=(archive=0)",
	",log=(archive=1)",
	",log=(prealloc=0)",
	",log=(prealloc=1)",
	",log=(zero_fill=0)",
	",log=(zero_fill=1)",

	",lsm_manager=(merge=0)",
	",lsm_manager=(merge=1)",
	",lsm_manager=(worker_thread_max=5)",
	",lsm_manager=(worker_thread_max=18)",
	",lsm_manager=(worker_thread_max=3)",

	",shared_cache=(chunk=20MB)",
	",shared_cache=(chunk=30MB)",
	",shared_cache=(chunk=5MB)",
	",shared_cache=(name=\"shared\")",
	",shared_cache=(name=\"none\")",
	",shared_cache=(quota=20MB)",
	",shared_cache=(quota=30MB)",
	",shared_cache=(quota=5MB)",
	",shared_cache=(quota=0)",
	",shared_cache=(reserve=20MB)",
	",shared_cache=(reserve=30MB)",
	",shared_cache=(reserve=5MB)",
	",shared_cache=(reserve=0)",
	",shared_cache=(size=100MB)",
	",shared_cache=(size=1GB)",
	",shared_cache=(size=75MB)",

	",statistics=(\"all\")",
	",statistics=(\"fast\")",
	",statistics=(\"none\")",
	",statistics=(\"all\",\"clear\")",
	",statistics=(\"fast\",\"clear\")",

	",statistics_log=(json=0)",
	",statistics_log=(json=1)",
	",statistics_log=(on_close=0)",
	",statistics_log=(on_close=1)",
	",statistics_log=(sources=(\"file:\"))",
	",statistics_log=(sources=())",
	",statistics_log=(timestamp=\"%b:%S\")",
	",statistics_log=(timestamp=\"%H:%M\")",
	",statistics_log=(wait=60)",
	",statistics_log=(wait=76)",
	",statistics_log=(wait=37)",
	",statistics_log=(wait=0)",

#ifdef HAVE_VERBOSE
	",verbose=(\"api\")",
	",verbose=(\"block\")",
	",verbose=(\"checkpoint\")",
	",verbose=(\"compact\")",
	",verbose=(\"evict\")",
	",verbose=(\"evictserver\")",
	",verbose=(\"fileops\")",
	",verbose=(\"handleops\")",
	",verbose=(\"log\")",
	",verbose=(\"lsm\")",
	",verbose=(\"lsm_manager\")",
	",verbose=(\"metadata\")",
	",verbose=(\"mutex\")",
	",verbose=(\"overflow\")",
	",verbose=(\"read\")",
	",verbose=(\"rebalance\")",
	",verbose=(\"reconcile\")",
	",verbose=(\"recovery\")",
	",verbose=(\"salvage\")",
	",verbose=(\"shared_cache\")",
	",verbose=(\"split\")",
	",verbose=(\"temporary\")",
	",verbose=(\"transaction\")",
	",verbose=(\"verify\")",
	",verbose=(\"version\")",
	",verbose=(\"write\")",
	",verbose=()"
#endif
};

static int
handle_message(WT_EVENT_HANDLER *handler,
    WT_SESSION *session, const char *message)
{
	(void)(handler);
	(void)(session);
	(void)(message);

	/* We configure verbose output, so just ignore. */
	return (0);
}

static WT_EVENT_HANDLER event_handler = { NULL, handle_message, NULL, NULL };

int
main(int argc, char *argv[])
{
	enum { CACHE_SHARED, CACHE_SET, CACHE_NONE } cache;
	TEST_OPTS *opts, _opts;
	WT_RAND_STATE rnd;
	WT_SESSION *session;
	size_t len;
	u_int i, j;
	int ret;
	const char *p;
	char *config;

	opts = &_opts;
	memset(opts, 0, sizeof(*opts));
	opts->table_type = TABLE_ROW;
	testutil_check(testutil_parse_opts(argc, argv, opts));
	testutil_make_work_dir(opts->home);

	testutil_check(
	    wiredtiger_open(opts->home, &event_handler, "create", &opts->conn));

	/* Open an LSM file so the LSM reconfiguration options make sense. */
	testutil_check(
	    opts->conn->open_session(opts->conn, NULL, NULL, &session));
	testutil_check(session->create(
	    session, opts->uri, "type=lsm,key_format=S,value_format=S"));

	/* Initialize the RNG. */
	testutil_check(__wt_random_init_seed(NULL, &rnd));

	/* Allocate memory for the config. */
	len = WT_ELEMENTS(list) * 64;
	config = dmalloc(len);

	/* A linear pass through the list. */
	for (i = 0; i < WT_ELEMENTS(list); ++i)
		if ((ret = opts->conn->reconfigure(opts->conn, list[i])) != 0) {
			fprintf(stderr, "%s: %s\n",
			    list[i], session->strerror(session, ret));
			return (EXIT_FAILURE);
		}

	/*
	 * A linear pass through the list, adding random elements.
	 *
	 * WiredTiger configurations are usually "the last one set wins", but
	 * "shared_cache" and "cache_set" options aren't allowed in the same
	 * configuration string.
	 */
	for (i = 0; i < WT_ELEMENTS(list); ++i) {
		p = list[i];
		cache = CACHE_NONE;
		if (WT_PREFIX_MATCH(p, ",shared_cache"))
			cache = CACHE_SHARED;
		else if (WT_PREFIX_MATCH(p, ",cache_size"))
			cache = CACHE_SET;
		strcpy(config, p);

		for (j =
		    (__wt_random(&rnd) % WT_ELEMENTS(list)) + 1; j > 0; --j) {
			p = list[__wt_random(&rnd) % WT_ELEMENTS(list)];
			if (WT_PREFIX_MATCH(p, ",shared_cache")) {
				if (cache == CACHE_SET)
					continue;
				cache = CACHE_SHARED;
			} else if (WT_PREFIX_MATCH(p, ",cache_size")) {
				if (cache == CACHE_SHARED)
					continue;
				cache = CACHE_SET;
			}
			strcat(config, p);
		}
		if ((ret = opts->conn->reconfigure(opts->conn, config)) != 0) {
			fprintf(stderr, "%s: %s\n",
			    config, session->strerror(session, ret));
			return (EXIT_FAILURE);
		}
	}

	/*
	 * Turn on-close statistics off, if on-close is on and statistics were
	 * randomly turned off during the run, close would fail.
	 */
	testutil_check(opts->conn->reconfigure(
	    opts->conn, "statistics_log=(on_close=0)"));

	free(config);
	testutil_cleanup(opts);
	return (EXIT_SUCCESS);
}