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

Commit5f1b00e

Browse files
committed
doc: Improve documentation about pg_resetwal -f option
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>Discussion:https://www.postgresql.org/message-id/flat/0f3ab4a1-ae80-56e8-3426-6b4a02507687@eisentraut.org
1 parenta11d8e1 commit5f1b00e

File tree

2 files changed

+53
-12
lines changed

2 files changed

+53
-12
lines changed

‎doc/src/sgml/ref/pg_resetwal.sgml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,33 @@ PostgreSQL documentation
5252
</para>
5353

5454
<para>
55-
After running this command, it should be possible to start the server,
55+
Some options, such as <option>--wal-segsize</option> (see below), can also
56+
be used to modify certain global settings of a database cluster without the
57+
need to rerun <command>initdb</command>. This can be done safely on an
58+
otherwise sound database cluster, if none of the dangerous modes mentioned
59+
below are used.
60+
</para>
61+
62+
<para>
63+
If <command>pg_resetwal</command> is used on a data directory where the
64+
server has been cleanly shut down and the control file is sound, then it
65+
will have no effect on the contents of the database system, except that no
66+
longer used WAL files are cleared away. Any other use is potentially
67+
dangerous and must be done with great care. <command>pg_resetwal</command>
68+
will require the <option>-f</option> (force) option to be specified before
69+
working on a data directory in an unclean shutdown state or with a
70+
corrupted control file.
71+
</para>
72+
73+
<para>
74+
After running this command on a data directory with corrupted WAL or a
75+
corrupted control file, it should be possible to start the server,
5676
but bear in mind that the database might contain inconsistent data due to
5777
partially-committed transactions. You should immediately dump your data,
5878
run <command>initdb</command>, and restore. After restore, check for
5979
inconsistencies and repair as needed.
6080
</para>
6181

62-
<para>
63-
This utility can only be run by the user who installed the server, because
64-
it requires read/write access to the data directory.
65-
For safety reasons, you must specify the data directory on the command line.
66-
<command>pg_resetwal</command> does not use the environment variable
67-
<envar>PGDATA</envar>.
68-
</para>
69-
7082
<para>
7183
If <command>pg_resetwal</command> complains that it cannot determine
7284
valid data for <filename>pg_control</filename>, you can force it to proceed anyway
@@ -82,19 +94,41 @@ PostgreSQL documentation
8294
execute any data-modifying operations in the database before you dump,
8395
as any such action is likely to make the corruption worse.
8496
</para>
97+
98+
<para>
99+
This utility can only be run by the user who installed the server, because
100+
it requires read/write access to the data directory.
101+
</para>
85102
</refsect1>
86103

87104
<refsect1>
88105
<title>Options</title>
89106

90107
<variablelist>
108+
<varlistentry>
109+
<term><replaceable class="parameter">datadir</replaceable></term>
110+
<term><option>-D <replaceable class="parameter">datadir</replaceable></option></term>
111+
<term><option>--pgdata=<replaceable class="parameter">datadir</replaceable></option></term>
112+
<listitem>
113+
<para>
114+
Specifies the location of the database directory.
115+
For safety reasons, you must specify the data directory on the command
116+
line. <command>pg_resetwal</command> does not use the environment
117+
variable <envar>PGDATA</envar>.
118+
</para>
119+
</listitem>
120+
</varlistentry>
121+
91122
<varlistentry>
92123
<term><option>-f</option></term>
93124
<term><option>--force</option></term>
94125
<listitem>
95126
<para>
96-
Force <command>pg_resetwal</command> to proceed even if it cannot determine
97-
valid data for <filename>pg_control</filename>, as explained above.
127+
Force <command>pg_resetwal</command> to proceed even in situations where
128+
it could be dangerous, as explained above. Specifically, this option is
129+
required to proceed if the server had not been cleanly shut down or if
130+
<command>pg_resetwal</command> cannot determine valid data for
131+
<filename>pg_control</filename>.
98132
</para>
99133
</listitem>
100134
</varlistentry>
@@ -284,6 +318,12 @@ PostgreSQL documentation
284318
linkend="app-initdb"/> for more information.
285319
</para>
286320

321+
<para>
322+
This option can also be used to change the WAL segment size of an
323+
existing database cluster, avoiding the need to
324+
re-<command>initdb</command>.
325+
</para>
326+
287327
<note>
288328
<para>
289329
While <command>pg_resetwal</command> will set the WAL starting address

‎src/bin/pg_resetwal/pg_resetwal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,8 @@ usage(void)
11351135

11361136
printf(_("\nOptions:\n"));
11371137
printf(_(" [-D, --pgdata=]DATADIR data directory\n"));
1138-
printf(_(" -f, --force force update to be done\n"));
1138+
printf(_(" -f, --force force update to be done even after unclean shutdown or\n"
1139+
" if pg_control values had to be guessed\n"));
11391140
printf(_(" -n, --dry-run no update, just show what would be done\n"));
11401141
printf(_(" -V, --version output version information, then exit\n"));
11411142
printf(_(" -?, --help show this help, then exit\n"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp