Skip to content

Commit b741f4c

Browse files
committed
Add --clobber-cache option to initdb, for CCA testing.
Commit 4656e3d replaced the "#define CLOBBER_CACHE_ALWAYS" testing mechanism with a GUC, which has been a great help for doing cache-clobber testing in more efficient ways; but there is a gap in the implementation. The only way to do cache-clobber testing during an initdb run is to use the old method with #define, because one can't set the GUC from outside. Improve this by adding a switch to initdb for the purpose. (Perhaps someday we should let initdb pass through arbitrary "-c NAME=VALUE" switches. Quoting difficulties dissuaded me from attempting that right now, though.) Back-patch to v14 where 4656e3d came in. Discussion: https://postgr.es/m/1582507.1624227029@sss.pgh.pa.us
1 parent d700518 commit b741f4c

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

doc/src/sgml/ref/initdb.sgml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,17 @@ PostgreSQL documentation
388388
Other, less commonly used, options are also available:
389389

390390
<variablelist>
391+
<varlistentry>
392+
<term><option>--clobber-cache</option></term>
393+
<listitem>
394+
<para>
395+
Run the bootstrap backend with the
396+
<literal>debug_invalidate_system_caches_always=1</literal> option.
397+
This takes a very long time and is only of use for deep debugging.
398+
</para>
399+
</listitem>
400+
</varlistentry>
401+
391402
<varlistentry>
392403
<term><option>-d</option></term>
393404
<term><option>--debug</option></term>

src/bin/initdb/initdb.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ static bool authwarning = false;
202202
static const char *boot_options = "-F";
203203
static const char *backend_options = "--single -F -O -j -c search_path=pg_catalog -c exit_on_error=true";
204204

205+
/* Additional switches to pass to backend (either boot or standalone) */
206+
static char *extra_options = "";
207+
205208
static const char *const subdirs[] = {
206209
"global",
207210
"pg_wal/archive_status",
@@ -962,12 +965,12 @@ test_config_settings(void)
962965
test_buffs = MIN_BUFS_FOR_CONNS(test_conns);
963966

964967
snprintf(cmd, sizeof(cmd),
965-
"\"%s\" --boot -x0 %s "
968+
"\"%s\" --boot -x0 %s %s "
966969
"-c max_connections=%d "
967970
"-c shared_buffers=%d "
968971
"-c dynamic_shared_memory_type=%s "
969972
"< \"%s\" > \"%s\" 2>&1",
970-
backend_exec, boot_options,
973+
backend_exec, boot_options, extra_options,
971974
test_conns, test_buffs,
972975
dynamic_shared_memory_type,
973976
DEVNULL, DEVNULL);
@@ -998,12 +1001,12 @@ test_config_settings(void)
9981001
}
9991002

10001003
snprintf(cmd, sizeof(cmd),
1001-
"\"%s\" --boot -x0 %s "
1004+
"\"%s\" --boot -x0 %s %s "
10021005
"-c max_connections=%d "
10031006
"-c shared_buffers=%d "
10041007
"-c dynamic_shared_memory_type=%s "
10051008
"< \"%s\" > \"%s\" 2>&1",
1006-
backend_exec, boot_options,
1009+
backend_exec, boot_options, extra_options,
10071010
n_connections, test_buffs,
10081011
dynamic_shared_memory_type,
10091012
DEVNULL, DEVNULL);
@@ -1403,11 +1406,11 @@ bootstrap_template1(void)
14031406
unsetenv("PGCLIENTENCODING");
14041407

14051408
snprintf(cmd, sizeof(cmd),
1406-
"\"%s\" --boot -x1 -X %u %s %s %s",
1409+
"\"%s\" --boot -x1 -X %u %s %s %s %s",
14071410
backend_exec,
14081411
wal_segment_size_mb * (1024 * 1024),
14091412
data_checksums ? "-k" : "",
1410-
boot_options,
1413+
boot_options, extra_options,
14111414
debug ? "-d 5" : "");
14121415

14131416

@@ -2263,6 +2266,7 @@ usage(const char *progname)
22632266
printf(_(" -X, --waldir=WALDIR location for the write-ahead log directory\n"));
22642267
printf(_(" --wal-segsize=SIZE size of WAL segments, in megabytes\n"));
22652268
printf(_("\nLess commonly used options:\n"));
2269+
printf(_(" --clobber-cache use cache-clobbering debug option\n"));
22662270
printf(_(" -d, --debug generate lots of debugging output\n"));
22672271
printf(_(" -L DIRECTORY where to find the input files\n"));
22682272
printf(_(" -n, --no-clean do not clean up after errors\n"));
@@ -2863,8 +2867,8 @@ initialize_data_directory(void)
28632867
fflush(stdout);
28642868

28652869
snprintf(cmd, sizeof(cmd),
2866-
"\"%s\" %s template1 >%s",
2867-
backend_exec, backend_options,
2870+
"\"%s\" %s %s template1 >%s",
2871+
backend_exec, backend_options, extra_options,
28682872
DEVNULL);
28692873

28702874
PG_CMD_OPEN;
@@ -2943,6 +2947,7 @@ main(int argc, char *argv[])
29432947
{"wal-segsize", required_argument, NULL, 12},
29442948
{"data-checksums", no_argument, NULL, 'k'},
29452949
{"allow-group-access", no_argument, NULL, 'g'},
2950+
{"clobber-cache", no_argument, NULL, 14},
29462951
{NULL, 0, NULL, 0}
29472952
};
29482953

@@ -3084,6 +3089,11 @@ main(int argc, char *argv[])
30843089
case 'g':
30853090
SetDataDirectoryCreatePerm(PG_DIR_MODE_GROUP);
30863091
break;
3092+
case 14:
3093+
extra_options = psprintf("%s %s",
3094+
extra_options,
3095+
"-c debug_invalidate_system_caches_always=1");
3096+
break;
30873097
default:
30883098
/* getopt_long already emitted a complaint */
30893099
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy