checksums-tweaks.diff
text/x-patch
Filename: checksums-tweaks.diff
Type: text/x-patch
Part: 0
Message:
Re: Online enabling of checksums
Patch
Format: unified
| File | + | − |
|---|---|---|
| doc/src/sgml/wal.sgml | 7 | 4 |
| src/backend/access/transam/xlogfuncs.c | 11 | 0 |
| src/backend/postmaster/checksumhelper.c | 2 | 0 |
diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml
index 123638b..b0d082a 100644
--- a/doc/src/sgml/wal.sgml
+++ b/doc/src/sgml/wal.sgml
@@ -257,7 +257,7 @@
</para>
<para>
- When attempting to recover from corrupt data it may be necessarily to bypass the checksum
+ When attempting to recover from corrupt data it may be necessary to bypass the checksum
protection in order to recover data. To do this, temporarily set the configuration parameter
<xref linkend="guc-ignore-checksum-failure" />.
</para>
@@ -287,15 +287,17 @@
be visible to the process enabling checksums. It will also, for each database,
wait for all pre-existing temporary tables to get removed before it finishes.
If long-lived temporary tables are used in the application it may be necessary
- to terminate these application connections to allow the checksummer process
- to complete.
+ to terminate these application connections to allow the process to complete.
+ Information about open transactions and connections with temporary tables is
+ written to log.
</para>
<para>
If the cluster is stopped while in <literal>inprogress</literal> mode, for
any reason, then this process must be restarted manually. To do this,
re-execute the function <function>pg_enable_data_checksums()</function>
- once the cluster has been restarted.
+ once the cluster has been restarted. It is not possible to resume the work,
+ the process has to start from scratch.
</para>
<note>
@@ -317,6 +319,7 @@
<para>
<literal>template0</literal> is by default not accepting connections, to
enable checksums you'll need to temporarily make it accept connections.
+ See <xref linkend="sql-alterdatabase" /> for details.
</para>
</note>
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index 67b9cd8..b76b268 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -700,6 +700,11 @@ pg_backup_start_time(PG_FUNCTION_ARGS)
PG_RETURN_DATUM(xtime);
}
+/*
+ * Disables checksums for the cluster, unless already disabled.
+ *
+ * Has immediate effect - the checksums are set to off right away.
+ */
Datum
disable_data_checksums(PG_FUNCTION_ARGS)
{
@@ -718,6 +723,12 @@ disable_data_checksums(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+/*
+ * Enables checksums for the cluster, unless already enabled.
+ *
+ * Supports vacuum-like cost-based throttling, to limit system load.
+ * Starts a background worker that updates checksums on existing data.
+ */
Datum
enable_data_checksums(PG_FUNCTION_ARGS)
{
diff --git a/src/backend/postmaster/checksumhelper.c b/src/backend/postmaster/checksumhelper.c
index 84a8cc8..e1c34e8 100644
--- a/src/backend/postmaster/checksumhelper.c
+++ b/src/backend/postmaster/checksumhelper.c
@@ -653,6 +653,8 @@ BuildDatabaseList(void)
db->dboid = HeapTupleGetOid(tup);
db->dbname = pstrdup(NameStr(pgdb->datname));
+ elog(WARNING, "attempts = %d", db->attempts);
+ db->attempts = 0;
DatabaseList = lappend(DatabaseList, db);