Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita228cc1

Browse files
committed
Revert "Allow on-line enabling and disabling of data checksums"
This reverts the backend sides of commit1fde38b.I have, at least for now, left the pg_verify_checksums tool in place, asthis tool can be very valuable without the rest of the patch as well,and since it's a read-only tool that only runs when the cluster is downit should be a lot safer.
1 parent03c1179 commita228cc1

39 files changed

+34
-1658
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -19566,71 +19566,6 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
1956619566

1956719567
</sect2>
1956819568

19569-
<sect2 id="functions-admin-checksum">
19570-
<title>Data Checksum Functions</title>
19571-
19572-
<para>
19573-
The functions shown in <xref linkend="functions-checksums-table" /> can
19574-
be used to enable or disable data checksums in a running cluster.
19575-
See <xref linkend="checksums" /> for details.
19576-
</para>
19577-
19578-
<table id="functions-checksums-table">
19579-
<title>Checksum <acronym>SQL</acronym> Functions</title>
19580-
<tgroup cols="3">
19581-
<thead>
19582-
<row>
19583-
<entry>Function</entry>
19584-
<entry>Return Type</entry>
19585-
<entry>Description</entry>
19586-
</row>
19587-
</thead>
19588-
<tbody>
19589-
<row>
19590-
<entry>
19591-
<indexterm>
19592-
<primary>pg_enable_data_checksums</primary>
19593-
</indexterm>
19594-
<literal><function>pg_enable_data_checksums(<optional><parameter>cost_delay</parameter> <type>int</type>, <parameter>cost_limit</parameter> <type>int</type></optional>)</function></literal>
19595-
</entry>
19596-
<entry>
19597-
void
19598-
</entry>
19599-
<entry>
19600-
<para>
19601-
Initiates data checksums for the cluster. This will switch the data checksums mode
19602-
to <literal>in progress</literal> and start a background worker that will process
19603-
all data in the database and enable checksums for it. When all data pages have had
19604-
checksums enabled, the cluster will automatically switch to checksums
19605-
<literal>on</literal>.
19606-
</para>
19607-
<para>
19608-
If <parameter>cost_delay</parameter> and <parameter>cost_limit</parameter> are
19609-
specified, the speed of the process is throttled using the same principles as
19610-
<link linkend="runtime-config-resource-vacuum-cost">Cost-based Vacuum Delay</link>.
19611-
</para>
19612-
</entry>
19613-
</row>
19614-
<row>
19615-
<entry>
19616-
<indexterm>
19617-
<primary>pg_disable_data_checksums</primary>
19618-
</indexterm>
19619-
<literal><function>pg_disable_data_checksums()</function></literal>
19620-
</entry>
19621-
<entry>
19622-
void
19623-
</entry>
19624-
<entry>
19625-
Disables data checksums for the cluster.
19626-
</entry>
19627-
</row>
19628-
</tbody>
19629-
</tgroup>
19630-
</table>
19631-
19632-
</sect2>
19633-
1963419569
<sect2 id="functions-admin-dbobject">
1963519570
<title>Database Object Management Functions</title>
1963619571

‎doc/src/sgml/ref/initdb.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ PostgreSQL documentation
214214
<para>
215215
Use checksums on data pages to help detect corruption by the
216216
I/O system that would otherwise be silent. Enabling checksums
217-
may incur a noticeable performance penalty.If set, checksums
218-
are calculated for all objects, in all databases. See
219-
<xref linkend="checksums" />fordetails.
217+
may incur a noticeable performance penalty.This option can only
218+
be set during initialization, and cannot be changed later. If
219+
set,checksums are calculatedforall objects, in all databases.
220220
</para>
221221
</listitem>
222222
</varlistentry>

‎doc/src/sgml/reference.sgml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@
284284
&pgtestfsync;
285285
&pgtesttiming;
286286
&pgupgrade;
287-
&pgVerifyChecksums;
288287
&pgwaldump;
289288
&postgres;
290289
&postmaster;

‎doc/src/sgml/wal.sgml

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -230,87 +230,6 @@
230230
</para>
231231
</sect1>
232232

233-
<sect1 id="checksums">
234-
<title>Data checksums</title>
235-
<indexterm>
236-
<primary>checksums</primary>
237-
</indexterm>
238-
239-
<para>
240-
Data pages are not checksum protected by default, but this can optionally be enabled for a cluster.
241-
When enabled, each data page will be assigned a checksum that is updated when the page is
242-
written and verified every time the page is read. Only data pages are protected by checksums,
243-
internal data structures and temporary files are not.
244-
</para>
245-
246-
<para>
247-
Checksums are normally enabled when the cluster is initialized using
248-
<link linkend="app-initdb-data-checksums"><application>initdb</application></link>. They
249-
can also be enabled or disabled at runtime. In all cases, checksums are enabled or disabled
250-
at the full cluster level, and cannot be specified individually for databases or tables.
251-
</para>
252-
253-
<para>
254-
The current state of checksums in the cluster can be verified by viewing the value
255-
of the read-only configuration variable <xref linkend="guc-data-checksums" /> by
256-
issuing the command <command>SHOW data_checksums</command>.
257-
</para>
258-
259-
<para>
260-
When attempting to recover from corrupt data it may be necessary to bypass the checksum
261-
protection in order to recover data. To do this, temporarily set the configuration parameter
262-
<xref linkend="guc-ignore-checksum-failure" />.
263-
</para>
264-
265-
<sect2 id="checksums-enable-disable">
266-
<title>On-line enabling of checksums</title>
267-
268-
<para>
269-
Checksums can be enabled or disabled online, by calling the appropriate
270-
<link linkend="functions-admin-checksum">functions</link>.
271-
Disabling of checksums takes effect immediately when the function is called.
272-
</para>
273-
274-
<para>
275-
Enabling checksums will put the cluster in <literal>inprogress</literal> mode.
276-
During this time, checksums will be written but not verified. In addition to
277-
this, a background worker process is started that enables checksums on all
278-
existing data in the cluster. Once this worker has completed processing all
279-
databases in the cluster, the checksum mode will automatically switch to
280-
<literal>on</literal>.
281-
</para>
282-
283-
<para>
284-
The process will initially wait for all open transactions to finish before
285-
it starts, so that it can be certain that there are no tables that have been
286-
created inside a transaction that has not committed yet and thus would not
287-
be visible to the process enabling checksums. It will also, for each database,
288-
wait for all pre-existing temporary tables to get removed before it finishes.
289-
If long-lived temporary tables are used in the application it may be necessary
290-
to terminate these application connections to allow the process to complete.
291-
Information about open transactions and connections with temporary tables is
292-
written to log.
293-
</para>
294-
295-
<para>
296-
If the cluster is stopped while in <literal>inprogress</literal> mode, for
297-
any reason, then this process must be restarted manually. To do this,
298-
re-execute the function <function>pg_enable_data_checksums()</function>
299-
once the cluster has been restarted. It is not possible to resume the work,
300-
the process has to start over and re-process the cluster.
301-
</para>
302-
303-
<note>
304-
<para>
305-
Enabling checksums can cause significant I/O to the system, as most of the
306-
database pages will need to be rewritten, and will be written both to the
307-
data files and the WAL.
308-
</para>
309-
</note>
310-
311-
</sect2>
312-
</sect1>
313-
314233
<sect1 id="wal-intro">
315234
<title>Write-Ahead Logging (<acronym>WAL</acronym>)</title>
316235

‎src/backend/access/rmgrdesc/xlogdesc.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include"access/xlog.h"
1818
#include"access/xlog_internal.h"
1919
#include"catalog/pg_control.h"
20-
#include"storage/bufpage.h"
2120
#include"utils/guc.h"
2221
#include"utils/timestamp.h"
2322

@@ -138,18 +137,6 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
138137
xlrec.ThisTimeLineID,xlrec.PrevTimeLineID,
139138
timestamptz_to_str(xlrec.end_time));
140139
}
141-
elseif (info==XLOG_CHECKSUMS)
142-
{
143-
xl_checksum_statexlrec;
144-
145-
memcpy(&xlrec,rec,sizeof(xl_checksum_state));
146-
if (xlrec.new_checksumtype==PG_DATA_CHECKSUM_VERSION)
147-
appendStringInfo(buf,"on");
148-
elseif (xlrec.new_checksumtype==PG_DATA_CHECKSUM_INPROGRESS_VERSION)
149-
appendStringInfo(buf,"inprogress");
150-
else
151-
appendStringInfo(buf,"off");
152-
}
153140
}
154141

155142
constchar*
@@ -195,9 +182,6 @@ xlog_identify(uint8 info)
195182
caseXLOG_FPI_FOR_HINT:
196183
id="FPI_FOR_HINT";
197184
break;
198-
caseXLOG_CHECKSUMS:
199-
id="CHECKSUMS";
200-
break;
201185
}
202186

203187
returnid;

‎src/backend/access/transam/xlog.c

Lines changed: 6 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ static void SetLatestXTime(TimestampTz xtime);
856856
staticvoidSetCurrentChunkStartTime(TimestampTzxtime);
857857
staticvoidCheckRequiredParameterValues(void);
858858
staticvoidXLogReportParameters(void);
859-
staticvoidXlogChecksums(ChecksumTypenew_type);
860859
staticvoidcheckTimeLineSwitch(XLogRecPtrlsn,TimeLineIDnewTLI,
861860
TimeLineIDprevTLI);
862861
staticvoidLocalSetXLogInsertAllowed(void);
@@ -1034,7 +1033,7 @@ XLogInsertRecord(XLogRecData *rdata,
10341033
Assert(RedoRecPtr<Insert->RedoRecPtr);
10351034
RedoRecPtr=Insert->RedoRecPtr;
10361035
}
1037-
doPageWrites= (Insert->fullPageWrites||Insert->forcePageWrites||DataChecksumsInProgress());
1036+
doPageWrites= (Insert->fullPageWrites||Insert->forcePageWrites);
10381037

10391038
if (fpw_lsn!=InvalidXLogRecPtr&&fpw_lsn <=RedoRecPtr&&doPageWrites)
10401039
{
@@ -4674,6 +4673,10 @@ ReadControlFile(void)
46744673
(SizeOfXLogLongPHD-SizeOfXLogShortPHD);
46754674

46764675
CalculateCheckpointSegments();
4676+
4677+
/* Make the initdb settings visible as GUC variables, too */
4678+
SetConfigOption("data_checksums",DataChecksumsEnabled() ?"yes" :"no",
4679+
PGC_INTERNAL,PGC_S_OVERRIDE);
46774680
}
46784681

46794682
void
@@ -4745,90 +4748,12 @@ GetMockAuthenticationNonce(void)
47454748
* Are checksums enabled for data pages?
47464749
*/
47474750
bool
4748-
DataChecksumsNeedWrite(void)
4751+
DataChecksumsEnabled(void)
47494752
{
47504753
Assert(ControlFile!=NULL);
47514754
return (ControlFile->data_checksum_version>0);
47524755
}
47534756

4754-
bool
4755-
DataChecksumsNeedVerify(void)
4756-
{
4757-
Assert(ControlFile!=NULL);
4758-
4759-
/*
4760-
* Only verify checksums if they are fully enabled in the cluster. In
4761-
* inprogress state they are only updated, not verified.
4762-
*/
4763-
return (ControlFile->data_checksum_version==PG_DATA_CHECKSUM_VERSION);
4764-
}
4765-
4766-
bool
4767-
DataChecksumsInProgress(void)
4768-
{
4769-
Assert(ControlFile!=NULL);
4770-
return (ControlFile->data_checksum_version==PG_DATA_CHECKSUM_INPROGRESS_VERSION);
4771-
}
4772-
4773-
void
4774-
SetDataChecksumsInProgress(void)
4775-
{
4776-
Assert(ControlFile!=NULL);
4777-
if (ControlFile->data_checksum_version>0)
4778-
return;
4779-
4780-
XlogChecksums(PG_DATA_CHECKSUM_INPROGRESS_VERSION);
4781-
4782-
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
4783-
ControlFile->data_checksum_version=PG_DATA_CHECKSUM_INPROGRESS_VERSION;
4784-
UpdateControlFile();
4785-
LWLockRelease(ControlFileLock);
4786-
}
4787-
4788-
void
4789-
SetDataChecksumsOn(void)
4790-
{
4791-
Assert(ControlFile!=NULL);
4792-
4793-
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
4794-
4795-
if (ControlFile->data_checksum_version!=PG_DATA_CHECKSUM_INPROGRESS_VERSION)
4796-
{
4797-
LWLockRelease(ControlFileLock);
4798-
elog(ERROR,"Checksums not in inprogress mode");
4799-
}
4800-
4801-
ControlFile->data_checksum_version=PG_DATA_CHECKSUM_VERSION;
4802-
UpdateControlFile();
4803-
LWLockRelease(ControlFileLock);
4804-
4805-
XlogChecksums(PG_DATA_CHECKSUM_VERSION);
4806-
}
4807-
4808-
void
4809-
SetDataChecksumsOff(void)
4810-
{
4811-
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
4812-
4813-
ControlFile->data_checksum_version=0;
4814-
UpdateControlFile();
4815-
LWLockRelease(ControlFileLock);
4816-
4817-
XlogChecksums(0);
4818-
}
4819-
4820-
/* guc hook */
4821-
constchar*
4822-
show_data_checksums(void)
4823-
{
4824-
if (ControlFile->data_checksum_version==PG_DATA_CHECKSUM_VERSION)
4825-
return"on";
4826-
elseif (ControlFile->data_checksum_version==PG_DATA_CHECKSUM_INPROGRESS_VERSION)
4827-
return"inprogress";
4828-
else
4829-
return"off";
4830-
}
4831-
48324757
/*
48334758
* Returns a fake LSN for unlogged relations.
48344759
*
@@ -7863,16 +7788,6 @@ StartupXLOG(void)
78637788
*/
78647789
CompleteCommitTsInitialization();
78657790

7866-
/*
7867-
* If we reach this point with checksums in inprogress state, we notify
7868-
* the user that they need to manually restart the process to enable
7869-
* checksums.
7870-
*/
7871-
if (ControlFile->data_checksum_version==PG_DATA_CHECKSUM_INPROGRESS_VERSION)
7872-
ereport(WARNING,
7873-
(errmsg("checksum state is \"inprogress\" with no worker"),
7874-
errhint("Either disable or enable checksums by calling the pg_disable_data_checksums() or pg_enable_data_checksums() functions.")));
7875-
78767791
/*
78777792
* All done with end-of-recovery actions.
78787793
*
@@ -9626,22 +9541,6 @@ XLogReportParameters(void)
96269541
}
96279542
}
96289543

9629-
/*
9630-
* Log the new state of checksums
9631-
*/
9632-
staticvoid
9633-
XlogChecksums(ChecksumTypenew_type)
9634-
{
9635-
xl_checksum_statexlrec;
9636-
9637-
xlrec.new_checksumtype=new_type;
9638-
9639-
XLogBeginInsert();
9640-
XLogRegisterData((char*)&xlrec,sizeof(xl_checksum_state));
9641-
9642-
XLogInsert(RM_XLOG_ID,XLOG_CHECKSUMS);
9643-
}
9644-
96459544
/*
96469545
* Update full_page_writes in shared memory, and write an
96479546
* XLOG_FPW_CHANGE record if necessary.
@@ -10070,17 +9969,6 @@ xlog_redo(XLogReaderState *record)
100709969
/* Keep track of full_page_writes */
100719970
lastFullPageWrites=fpw;
100729971
}
10073-
elseif (info==XLOG_CHECKSUMS)
10074-
{
10075-
xl_checksum_statestate;
10076-
10077-
memcpy(&state,XLogRecGetData(record),sizeof(xl_checksum_state));
10078-
10079-
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
10080-
ControlFile->data_checksum_version=state.new_checksumtype;
10081-
UpdateControlFile();
10082-
LWLockRelease(ControlFileLock);
10083-
}
100849972
}
100859973

100869974
#ifdefWAL_DEBUG

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp