aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2013-03-22 13:54:07 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2013-03-22 13:54:07 +0000
commit96ef3b8ff1cf1950e897fd2f766d4bd9ef0d5d56 (patch)
tree65849014627f4e211c6be8a4e9905b67694ed4ae /src/bin
parente4a05c7512b23c8f48c186e685f2ef186374a20a (diff)
downloadpostgresql-96ef3b8ff1cf1950e897fd2f766d4bd9ef0d5d56.tar.gz
postgresql-96ef3b8ff1cf1950e897fd2f766d4bd9ef0d5d56.zip
Allow I/O reliability checks using 16-bit checksums
Checksums are set immediately prior to flush out of shared buffers and checked when pages are read in again. Hint bit setting will require full page write when block is dirtied, which causes various infrastructure changes. Extensive comments, docs and README. WARNING message thrown if checksum fails on non-all zeroes page; ERROR thrown but can be disabled with ignore_checksum_failure = on. Feature enabled by an initdb option, since transition from option off to option on is long and complex and has not yet been implemented. Default is not to use checksums. Checksum used is WAL CRC-32 truncated to 16-bits. Simon Riggs, Jeff Davis, Greg Smith Wide input and assistance from many community members. Thank you.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/initdb/initdb.c19
-rw-r--r--src/bin/pg_controldata/pg_controldata.c2
-rw-r--r--src/bin/pg_resetxlog/pg_resetxlog.c2
3 files changed, 20 insertions, 3 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index e16f3e3c80a..bb38796eb28 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -119,6 +119,7 @@ static bool noclean = false;
static bool do_sync = true;
static bool sync_only = false;
static bool show_setting = false;
+static bool data_checksums = false;
static char *xlog_dir = "";
@@ -1441,8 +1442,10 @@ bootstrap_template1(void)
unsetenv("PGCLIENTENCODING");
snprintf(cmd, sizeof(cmd),
- "\"%s\" --boot -x1 %s %s",
- backend_exec, boot_options, talkargs);
+ "\"%s\" --boot -x1 %s %s %s",
+ backend_exec,
+ data_checksums ? "-k" : "",
+ boot_options, talkargs);
PG_CMD_OPEN;
@@ -2748,6 +2751,7 @@ usage(const char *progname)
printf(_(" -X, --xlogdir=XLOGDIR location for the transaction log directory\n"));
printf(_("\nLess commonly used options:\n"));
printf(_(" -d, --debug generate lots of debugging output\n"));
+ printf(_(" -k, --data-checksums data page checksums\n"));
printf(_(" -L DIRECTORY where to find the input files\n"));
printf(_(" -n, --noclean do not clean up after errors\n"));
printf(_(" -N, --nosync do not wait for changes to be written safely to disk\n"));
@@ -3424,6 +3428,7 @@ main(int argc, char *argv[])
{"nosync", no_argument, NULL, 'N'},
{"sync-only", no_argument, NULL, 'S'},
{"xlogdir", required_argument, NULL, 'X'},
+ {"data-checksums", no_argument, NULL, 'k'},
{NULL, 0, NULL, 0}
};
@@ -3455,7 +3460,7 @@ main(int argc, char *argv[])
/* process command-line options */
- while ((c = getopt_long(argc, argv, "dD:E:L:nNU:WA:sST:X:", long_options, &option_index)) != -1)
+ while ((c = getopt_long(argc, argv, "dD:E:kL:nNU:WA:sST:X:", long_options, &option_index)) != -1)
{
switch (c)
{
@@ -3504,6 +3509,9 @@ main(int argc, char *argv[])
case 'S':
sync_only = true;
break;
+ case 'k':
+ data_checksums = true;
+ break;
case 'L':
share_path = pg_strdup(optarg);
break;
@@ -3615,6 +3623,11 @@ main(int argc, char *argv[])
setup_locale_encoding();
setup_text_search();
+
+ if (data_checksums)
+ printf(_("Data page checksums are enabled.\n"));
+ else
+ printf(_("Data page checksums are disabled.\n"));
printf("\n");
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 369f2fb0759..ceb412505bf 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -287,5 +287,7 @@ main(int argc, char *argv[])
(ControlFile.float4ByVal ? _("by value") : _("by reference")));
printf(_("Float8 argument passing: %s\n"),
(ControlFile.float8ByVal ? _("by value") : _("by reference")));
+ printf(_("Data page checksums: %s\n"),
+ (ControlFile.data_checksums ? _("enabled") : _("disabled")));
return 0;
}
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index acf9f8dd3e3..124dcfb7772 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -624,6 +624,8 @@ PrintControlValues(bool guessed)
(ControlFile.float4ByVal ? _("by value") : _("by reference")));
printf(_("Float8 argument passing: %s\n"),
(ControlFile.float8ByVal ? _("by value") : _("by reference")));
+ printf(_("Data page checksums: %s\n"),
+ (ControlFile.data_checksums ? _("enabled") : _("disabled")));
}