Commit d0477080 authored by Tom Lane's avatar Tom Lane

Add --clobber-cache option to initdb, for CCA testing.

Commit 4656e3d6 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 4656e3d6 came in.

Discussion: https://postgr.es/m/1582507.1624227029@sss.pgh.pa.us
parent be280cda
...@@ -388,6 +388,17 @@ PostgreSQL documentation ...@@ -388,6 +388,17 @@ PostgreSQL documentation
Other, less commonly used, options are also available: Other, less commonly used, options are also available:
<variablelist> <variablelist>
<varlistentry>
<term><option>--clobber-cache</option></term>
<listitem>
<para>
Run the bootstrap backend with the
<literal>debug_invalidate_system_caches_always=1</literal> option.
This takes a very long time and is only of use for deep debugging.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-d</option></term> <term><option>-d</option></term>
<term><option>--debug</option></term> <term><option>--debug</option></term>
......
...@@ -202,6 +202,9 @@ static bool authwarning = false; ...@@ -202,6 +202,9 @@ static bool authwarning = false;
static const char *boot_options = "-F"; static const char *boot_options = "-F";
static const char *backend_options = "--single -F -O -j -c search_path=pg_catalog -c exit_on_error=true"; static const char *backend_options = "--single -F -O -j -c search_path=pg_catalog -c exit_on_error=true";
/* Additional switches to pass to backend (either boot or standalone) */
static char *extra_options = "";
static const char *const subdirs[] = { static const char *const subdirs[] = {
"global", "global",
"pg_wal/archive_status", "pg_wal/archive_status",
...@@ -962,12 +965,12 @@ test_config_settings(void) ...@@ -962,12 +965,12 @@ test_config_settings(void)
test_buffs = MIN_BUFS_FOR_CONNS(test_conns); test_buffs = MIN_BUFS_FOR_CONNS(test_conns);
snprintf(cmd, sizeof(cmd), snprintf(cmd, sizeof(cmd),
"\"%s\" --boot -x0 %s " "\"%s\" --boot -x0 %s %s "
"-c max_connections=%d " "-c max_connections=%d "
"-c shared_buffers=%d " "-c shared_buffers=%d "
"-c dynamic_shared_memory_type=%s " "-c dynamic_shared_memory_type=%s "
"< \"%s\" > \"%s\" 2>&1", "< \"%s\" > \"%s\" 2>&1",
backend_exec, boot_options, backend_exec, boot_options, extra_options,
test_conns, test_buffs, test_conns, test_buffs,
dynamic_shared_memory_type, dynamic_shared_memory_type,
DEVNULL, DEVNULL); DEVNULL, DEVNULL);
...@@ -998,12 +1001,12 @@ test_config_settings(void) ...@@ -998,12 +1001,12 @@ test_config_settings(void)
} }
snprintf(cmd, sizeof(cmd), snprintf(cmd, sizeof(cmd),
"\"%s\" --boot -x0 %s " "\"%s\" --boot -x0 %s %s "
"-c max_connections=%d " "-c max_connections=%d "
"-c shared_buffers=%d " "-c shared_buffers=%d "
"-c dynamic_shared_memory_type=%s " "-c dynamic_shared_memory_type=%s "
"< \"%s\" > \"%s\" 2>&1", "< \"%s\" > \"%s\" 2>&1",
backend_exec, boot_options, backend_exec, boot_options, extra_options,
n_connections, test_buffs, n_connections, test_buffs,
dynamic_shared_memory_type, dynamic_shared_memory_type,
DEVNULL, DEVNULL); DEVNULL, DEVNULL);
...@@ -1403,11 +1406,11 @@ bootstrap_template1(void) ...@@ -1403,11 +1406,11 @@ bootstrap_template1(void)
unsetenv("PGCLIENTENCODING"); unsetenv("PGCLIENTENCODING");
snprintf(cmd, sizeof(cmd), snprintf(cmd, sizeof(cmd),
"\"%s\" --boot -x1 -X %u %s %s %s", "\"%s\" --boot -x1 -X %u %s %s %s %s",
backend_exec, backend_exec,
wal_segment_size_mb * (1024 * 1024), wal_segment_size_mb * (1024 * 1024),
data_checksums ? "-k" : "", data_checksums ? "-k" : "",
boot_options, boot_options, extra_options,
debug ? "-d 5" : ""); debug ? "-d 5" : "");
...@@ -2263,6 +2266,7 @@ usage(const char *progname) ...@@ -2263,6 +2266,7 @@ usage(const char *progname)
printf(_(" -X, --waldir=WALDIR location for the write-ahead log directory\n")); printf(_(" -X, --waldir=WALDIR location for the write-ahead log directory\n"));
printf(_(" --wal-segsize=SIZE size of WAL segments, in megabytes\n")); printf(_(" --wal-segsize=SIZE size of WAL segments, in megabytes\n"));
printf(_("\nLess commonly used options:\n")); printf(_("\nLess commonly used options:\n"));
printf(_(" --clobber-cache use cache-clobbering debug option\n"));
printf(_(" -d, --debug generate lots of debugging output\n")); printf(_(" -d, --debug generate lots of debugging output\n"));
printf(_(" -L DIRECTORY where to find the input files\n")); printf(_(" -L DIRECTORY where to find the input files\n"));
printf(_(" -n, --no-clean do not clean up after errors\n")); printf(_(" -n, --no-clean do not clean up after errors\n"));
...@@ -2863,8 +2867,8 @@ initialize_data_directory(void) ...@@ -2863,8 +2867,8 @@ initialize_data_directory(void)
fflush(stdout); fflush(stdout);
snprintf(cmd, sizeof(cmd), snprintf(cmd, sizeof(cmd),
"\"%s\" %s template1 >%s", "\"%s\" %s %s template1 >%s",
backend_exec, backend_options, backend_exec, backend_options, extra_options,
DEVNULL); DEVNULL);
PG_CMD_OPEN; PG_CMD_OPEN;
...@@ -2943,6 +2947,7 @@ main(int argc, char *argv[]) ...@@ -2943,6 +2947,7 @@ main(int argc, char *argv[])
{"wal-segsize", required_argument, NULL, 12}, {"wal-segsize", required_argument, NULL, 12},
{"data-checksums", no_argument, NULL, 'k'}, {"data-checksums", no_argument, NULL, 'k'},
{"allow-group-access", no_argument, NULL, 'g'}, {"allow-group-access", no_argument, NULL, 'g'},
{"clobber-cache", no_argument, NULL, 14},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
...@@ -3084,6 +3089,11 @@ main(int argc, char *argv[]) ...@@ -3084,6 +3089,11 @@ main(int argc, char *argv[])
case 'g': case 'g':
SetDataDirectoryCreatePerm(PG_DIR_MODE_GROUP); SetDataDirectoryCreatePerm(PG_DIR_MODE_GROUP);
break; break;
case 14:
extra_options = psprintf("%s %s",
extra_options,
"-c debug_invalidate_system_caches_always=1");
break;
default: default:
/* getopt_long already emitted a complaint */ /* getopt_long already emitted a complaint */
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment