11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_resetxlog.sgml,v 1.5 2002/08/29 22:19:03 petere Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_resetxlog.sgml,v 1.6 2002/10/02 21:30:13 tgl Exp $
33PostgreSQL documentation
44-->
55
@@ -12,14 +12,15 @@ PostgreSQL documentation
1212
1313 <refnamediv>
1414 <refname>pg_resetxlog</refname>
15- <refpurpose>reset write-ahead logfile andoptionally the pg_controlfile </refpurpose>
15+ <refpurpose>reset write-ahead log and pg_controlcontents </refpurpose>
1616 </refnamediv>
1717
1818 <refsynopsisdiv>
1919 <cmdsynopsis>
2020 <command>pg_resetxlog</command>
2121 <arg> -f </arg>
2222 <arg> -n </arg>
23+ <arg> -o <replaceable class="parameter">oid</replaceable> </arg>
2324 <arg> -x <replaceable class="parameter">xid</replaceable> </arg>
2425 <arg> -l <replaceable class="parameter">fileid</replaceable>,<replaceable class="parameter">seg</replaceable> </arg>
2526 <arg choice="plain"><replaceable>datadir</replaceable></arg>
@@ -29,8 +30,9 @@ PostgreSQL documentation
2930 <refsect1 id="R1-APP-PGRESETXLOG-1">
3031 <title>Description</title>
3132 <para>
32- <command>pg_resetxlog</command> clears the write-ahead log file and
33- optionally the <filename>pg_control</> file. This function is sometimes
33+ <command>pg_resetxlog</command> clears the write-ahead log and
34+ optionally resets some fields in the <filename>pg_control</> file. This
35+ function is sometimes
3436 needed if these files have become corrupted.
3537 It should be used only as a last resort,
3638 when the server will not start due to such corruption.
@@ -55,27 +57,52 @@ PostgreSQL documentation
5557 <para>
5658 If <command>pg_resetxlog</command> complains that it cannot determine
5759 valid data for <filename>pg_control</>, you can force it to proceed anyway
58- by specifying the <literal>-f</> (force) switch. In this case plausible values
59- will be substituted for the missing data. If <literal>-f</> is used then
60+ by specifying the <literal>-f</> (force) switch. In this case plausible
61+ values will be substituted for the missing data. Most of the fields can be
62+ expected to match, but manual assistance may be needed for the next OID,
63+ next transaction ID, WAL starting address, and database locale fields.
64+ The first three of these can be set using the switches discussed below.
65+ <command>pg_resetxlog</command>'s own environment is the source for its
66+ guess at the locale fields; take care that <envar>LANG</> and so forth
67+ match the environment that <application>initdb</> was run in.
68+ If you are not able to determine correct values for all these fields,
69+ <literal>-f</> can still be used, but
6070 the recovered database must be treated with even more suspicion than
6171 usual --- an immediate dump and reload is imperative. <emphasis>Do not</>
6272 execute any data-modifying operations in the database before you dump,
6373 as any such action is likely to make the corruption worse.
6474 </para>
6575
76+ <para>
77+ The <literal>-o</>, <literal>-x</>, and <literal>-l</> switches allow
78+ the next OID, next transaction ID, and WAL starting address values to
79+ be set manually. These are only needed when
80+ <command>pg_resetxlog</command> is unable to determine appropriate values
81+ by reading <filename>pg_control</>. A safe value for the
82+ next transaction ID may be determined by looking for the largest
83+ file name in <envar>$PGDATA</><filename>/pg_clog</>, adding one,
84+ and then multiplying by 1048576. Note that the file names are in
85+ hexadecimal. It is usually easiest to specify the switch value in
86+ hexadecimal too. For example, if <filename>0011</> is the largest entry
87+ in <filename>pg_clog</>, <literal>-x 0x1200000</> will work (five trailing
88+ zeroes provide the proper multiplier).
89+ The WAL starting address should be
90+ larger than any file number currently existing in
91+ <envar>$PGDATA</><filename>/pg_xlog</>. These also are in hex, and
92+ have two parts. For example, if <filename>000000FF0000003A</> is the
93+ largest entry in <filename>pg_xlog</>, <literal>-l 0xFF,0x3B</> will work.
94+ There is no comparably easy way to determine a next OID that's beyond
95+ the largest one in the database, but fortunately it is not critical to
96+ get the next-OID setting right.
97+ </para>
98+
6699 <para>
67100 The <literal>-n</> (no operation) switch instructs
68101 <command>pg_resetxlog</command> to print the values reconstructed from
69102 <filename>pg_control</> and then exit without modifying anything.
70103 This is mainly a debugging tool, but may be useful as a sanity check
71104 before allowing <command>pg_resetxlog</command> to proceed for real.
72105 </para>
73-
74- <para>
75- The <literal>-x</> and <literal>-l</> switches are intended for use by
76- <application>pg_upgrade</>. In most cases they should not be used in
77- manual recovery operations.
78- </para>
79106 </refsect1>
80107
81108 <refsect1>