1
1
<!--
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 $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -12,14 +12,15 @@ PostgreSQL documentation
12
12
13
13
<refnamediv>
14
14
<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>
16
16
</refnamediv>
17
17
18
18
<refsynopsisdiv>
19
19
<cmdsynopsis>
20
20
<command>pg_resetxlog</command>
21
21
<arg> -f </arg>
22
22
<arg> -n </arg>
23
+ <arg> -o <replaceable class="parameter">oid</replaceable> </arg>
23
24
<arg> -x <replaceable class="parameter">xid</replaceable> </arg>
24
25
<arg> -l <replaceable class="parameter">fileid</replaceable>,<replaceable class="parameter">seg</replaceable> </arg>
25
26
<arg choice="plain"><replaceable>datadir</replaceable></arg>
@@ -29,8 +30,9 @@ PostgreSQL documentation
29
30
<refsect1 id="R1-APP-PGRESETXLOG-1">
30
31
<title>Description</title>
31
32
<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
34
36
needed if these files have become corrupted.
35
37
It should be used only as a last resort,
36
38
when the server will not start due to such corruption.
@@ -55,27 +57,52 @@ PostgreSQL documentation
55
57
<para>
56
58
If <command>pg_resetxlog</command> complains that it cannot determine
57
59
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
60
70
the recovered database must be treated with even more suspicion than
61
71
usual --- an immediate dump and reload is imperative. <emphasis>Do not</>
62
72
execute any data-modifying operations in the database before you dump,
63
73
as any such action is likely to make the corruption worse.
64
74
</para>
65
75
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
+
66
99
<para>
67
100
The <literal>-n</> (no operation) switch instructs
68
101
<command>pg_resetxlog</command> to print the values reconstructed from
69
102
<filename>pg_control</> and then exit without modifying anything.
70
103
This is mainly a debugging tool, but may be useful as a sanity check
71
104
before allowing <command>pg_resetxlog</command> to proceed for real.
72
105
</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>
79
106
</refsect1>
80
107
81
108
<refsect1>