mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
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.
This commit is contained in:
@ -56,6 +56,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
bool got_toast = false;
|
||||
bool got_date_is_int = false;
|
||||
bool got_float8_pass_by_value = false;
|
||||
bool got_data_checksums = false;
|
||||
char *lc_collate = NULL;
|
||||
char *lc_ctype = NULL;
|
||||
char *lc_monetary = NULL;
|
||||
@ -131,6 +132,13 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
got_float8_pass_by_value = true;
|
||||
}
|
||||
|
||||
/* Only in <= 9.2 */
|
||||
if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
|
||||
{
|
||||
cluster->controldata.data_checksums = false;
|
||||
got_data_checksums = true;
|
||||
}
|
||||
|
||||
/* we have the result of cmd in "output". so parse it line by line now */
|
||||
while (fgets(bufin, sizeof(bufin), output))
|
||||
{
|
||||
@ -393,6 +401,18 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
cluster->controldata.float8_pass_by_value = strstr(p, "by value") != NULL;
|
||||
got_float8_pass_by_value = true;
|
||||
}
|
||||
else if ((p = strstr(bufin, "checksums")) != NULL)
|
||||
{
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
/* used later for contrib check */
|
||||
cluster->controldata.data_checksums = strstr(p, "enabled") != NULL;
|
||||
got_data_checksums = true;
|
||||
}
|
||||
/* In pre-8.4 only */
|
||||
else if ((p = strstr(bufin, "LC_COLLATE:")) != NULL)
|
||||
{
|
||||
@ -476,7 +496,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
!got_tli ||
|
||||
!got_align || !got_blocksz || !got_largesz || !got_walsz ||
|
||||
!got_walseg || !got_ident || !got_index || !got_toast ||
|
||||
!got_date_is_int || !got_float8_pass_by_value)
|
||||
!got_date_is_int || !got_float8_pass_by_value || !got_data_checksums)
|
||||
{
|
||||
pg_log(PG_REPORT,
|
||||
"The %s cluster lacks some required control information:\n",
|
||||
@ -535,6 +555,10 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
if (!got_float8_pass_by_value)
|
||||
pg_log(PG_REPORT, " float8 argument passing method\n");
|
||||
|
||||
/* value added in Postgres 9.3 */
|
||||
if (!got_data_checksums)
|
||||
pg_log(PG_REPORT, " data checksums\n");
|
||||
|
||||
pg_log(PG_FATAL,
|
||||
"Cannot continue without required control information, terminating\n");
|
||||
}
|
||||
@ -596,6 +620,12 @@ check_control_data(ControlData *oldctrl,
|
||||
"--disable-integer-datetimes or get server binaries built with those\n"
|
||||
"options.\n");
|
||||
}
|
||||
|
||||
if (oldctrl->data_checksums != newctrl->data_checksums)
|
||||
{
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata checksums settings are invalid or do not match\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -202,6 +202,7 @@ typedef struct
|
||||
uint32 toast;
|
||||
bool date_is_int;
|
||||
bool float8_pass_by_value;
|
||||
bool data_checksums;
|
||||
char *lc_collate;
|
||||
char *lc_ctype;
|
||||
char *encoding;
|
||||
|
Reference in New Issue
Block a user