{"kind": "tool", "major": "18", "item": {"slug": "pg-resetwal", "name": "pg_resetwal", "name_zh": "", "category": "Server applications", "summary": "pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster", "aliases": ["pg_resetwal"], "content_hash": "7d3e088ec3d8c979a26639759d6cd56e87f8c986b8e8298904fa773a00cec5e1", "versions": {"10": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "10.23"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "12"}], "tables": [{"key": "options", "rows": [{"summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-f"}}, {"summary": "The -n (no operation) option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-n"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-c xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-e xid_epoch"}}, {"summary": "Manually set the WAL starting address.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-l walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-m mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-o oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-O mxoff"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-u xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/10/app-pgresetwal.html", "text": "-x xid"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}], "options": [{"names": ["-f"], "summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": "-f", "source_url": "/docs/10/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n"], "summary": "The -n (no operation) option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n", "source_url": "/docs/10/app-pgresetwal.html", "description": "The -n (no operation) option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/10/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/10/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid", "source_url": "/docs/10/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch", "source_url": "/docs/10/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l"], "summary": "Manually set the WAL starting address.", "signature": "-l walfile", "source_url": "/docs/10/app-pgresetwal.html", "description": "Manually set the WAL starting address. The WAL starting address should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid", "source_url": "/docs/10/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o"], "summary": "Manually set the next OID.", "signature": "-o oid", "source_url": "/docs/10/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff", "source_url": "/docs/10/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid", "source_url": "/docs/10/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x"], "summary": "Manually set the next transaction ID.", "signature": "-x xid", "source_url": "/docs/10/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "label": "10.23", "major": "10", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/10/postgresql-10-A4.pdf", "bytes": 12631706, "pages": 2591, "sha256": "34497ab9efb45c5bdf1bd11b9016b5451354feb462fa029cf74557a5fa5fbbc1", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/10/postgresql-10-US.pdf", "bytes": 12531684, "pages": 2724, "sha256": "429cc7133ddf4f97c560aa466dc9caea4b718721a8321e293357037cf0af4733", "built_at": "2026-09-26"}}, "tree": "10", "index": "index.html", "major": "10", "pages": 1085, "release": "10.23", "source_url": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea", "evidence_kind": "English manual and source declarations", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "sources": [{"url": "/docs/10/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "10.23 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "a4826a13c3abe474166187a827b7881b6ed79aca9a16c8931ff7a6e63e2ab343"}, {"url": "/docs/10/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "2a6043b88501763a31348758a370a42cd7f9a179c7fdf3ef0e353c82e95b33e9"}], "sections": [], "synopsis": ["pg_resetwal [ -f ] [ -n ] [ option ...] {[ -D ] datadir }"], "signature": "pg_resetwal [ -f ] [ -n ] [ option ...] {[ -D ] datadir }", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.1\"><code class=\"command\">pg_resetwal</code> [<code class=\"option\">-f</code>] [<code class=\"option\">-n</code>] [<em class=\"replaceable\"><code>option</code></em>...] {[<code class=\"option\">-D</code>] <em class=\"replaceable\"><code>datadir</code></em>}</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>After running this command, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and reload. After reload, check for inconsistencies and repair as needed.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting address fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and reload is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-f</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even if it cannot determine valid data for <code class=\"filename\">pg_control</code>, as explained above.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code> (no operation) option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code> <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e</code> <em class=\"replaceable\"><code>xid_epoch</code></em></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l</code> <em class=\"replaceable\"><code>walfile</code></em></span></dt>\n<dd>\n<p>Manually set the WAL starting address.</p>\n<p>The WAL starting address should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m</code> <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>oid</code></em></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>mxoff</code></em></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code> <em class=\"replaceable\"><code>xid</code></em></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.7\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.8\">\n<h2>See Also</h2>\n<span class=\"simplelist\"><a class=\"xref\" href=\"/docs/10/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span></div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-f"], "signature": "-f", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n"], "signature": "-n", "description": "The -n (no operation) option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c"], "signature": "-c xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e"], "signature": "-e xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l"], "signature": "-l walfile", "description": "Manually set the WAL starting address. The WAL starting address should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m"], "signature": "-m mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o"], "signature": "-o oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O"], "signature": "-O mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid"], "signature": "-u xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x"], "signature": "-x xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "synopsis": ["pg_resetwal [ -f ] [ -n ] [ option ...] {[ -D ] datadir }"], "environment": []}, "comparison_hash": "87e4873e91ae8c87638ede399bedc1c8aa5f7d4790a77b11fb558a296e0fa027"}, "11": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "11.22"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "13"}], "tables": [{"key": "options", "rows": [{"summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/11/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}], "options": [{"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": "-f --force", "source_url": "/docs/11/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/11/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/11/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/11/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/11/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/11/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/11/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/11/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/11/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/11/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/11/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/11/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/11/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "label": "11.22", "major": "11", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/11/postgresql-11-A4.pdf", "bytes": 13057499, "pages": 2732, "sha256": "41d75855e610d0d9b8802b87dc5b080bef8d7e91c7cf69401fbf8d3cf801b4b5", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/11/postgresql-11-US.pdf", "bytes": 12961189, "pages": 2883, "sha256": "6a8899ef36935a5b7ed2b436207564a567a4ef1eb1c2200195876b8de4d4fa30", "built_at": "2026-09-26"}}, "tree": "11", "index": "index.html", "major": "11", "pages": 1125, "release": "11.22", "source_url": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f", "evidence_kind": "English manual and source declarations", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "sources": [{"url": "/docs/11/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "11.22 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "2d28b058764b1790c167f4839e20e0905714928c06cda8da1493a79564d2f8a6"}, {"url": "/docs/11/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e940a8505b6742c717a1683d19bf8f759aad245633a59db9e83a345ae7c5709a"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>After running this command, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even if it cannot determine valid data for <code class=\"filename\">pg_control</code>, as explained above.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/11/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a> for more information.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.7\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.8\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/11/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": []}, "comparison_hash": "07b0ba07ad755ac0fe1b497421822181b385113adaa7e17e28f93987bccfa350"}, "12": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "12.22"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "13"}], "tables": [{"key": "options", "rows": [{"summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/12/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": "-f --force", "source_url": "/docs/12/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/12/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/12/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/12/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/12/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/12/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/12/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/12/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/12/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/12/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/12/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/12/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/12/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "label": "12.22", "major": "12", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/12/postgresql-12-A4.pdf", "bytes": 13424351, "pages": 2803, "sha256": "7422cf53fd1939e7a3d2925231a88b0330e468afa5393627cac0ff86158a0621", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/12/postgresql-12-US.pdf", "bytes": 13322565, "pages": 2958, "sha256": "51f3b04e72907fc38512685946223452ea65f84419c60c66241dfa3396035e77", "built_at": "2026-09-26"}}, "tree": "12", "index": "index.html", "major": "12", "pages": 1131, "release": "12.22", "source_url": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "svg_assets": 2, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4", "evidence_kind": "English manual and source declarations", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "sources": [{"url": "/docs/12/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "12.22 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "d3de187c3203452690b25de22ee7627607fe41265d88d2b00549a0cd3d3675c1"}, {"url": "/docs/12/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "7f6ae1fadc1b0bffa606551460e62aacdc2508a3fb66566ddae861928ca6080b"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>After running this command, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even if it cannot determine valid data for <code class=\"filename\">pg_control</code>, as explained above.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/12/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a> for more information.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/12/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "2e75a1fb3e22e5af38c29ab81b14d4bdbfd53bd0d273146c3a3372d6c8d19a7a"}, "13": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "13.23"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "13"}], "tables": [{"key": "options", "rows": [{"summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/13/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": "-f --force", "source_url": "/docs/13/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/13/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/13/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/13/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/13/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/13/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/13/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/13/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/13/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/13/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/13/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/13/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/13/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "label": "13.23", "major": "13", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/13/postgresql-13-A4.pdf", "bytes": 13843239, "pages": 2826, "sha256": "171cc09f90936dbc1cbd503a98ff07ae72ea58ab9771ff051313f1217737799c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/13/postgresql-13-US.pdf", "bytes": 13739572, "pages": 2984, "sha256": "48d09c6e197d9db4220f41afe83efe848a8661b1b168d3b89419751ecaf6c24d", "built_at": "2026-09-26"}}, "tree": "13", "index": "index.html", "major": "13", "pages": 1139, "release": "13.23", "source_url": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6", "evidence_kind": "English manual and source declarations", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "sources": [{"url": "/docs/13/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "13.23 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "27e7cee86054c4d788d97bf5b3bed2c180363b9215419e43379061bb434e071a"}, {"url": "/docs/13/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "074ef8577fd368272a2360309e1226e2d0b1e570a3e1da62dfcca63ac9ee5539"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>After running this command, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even if it cannot determine valid data for <code class=\"filename\">pg_control</code>, as explained above.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/13/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a> for more information.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/13/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "2e75a1fb3e22e5af38c29ab81b14d4bdbfd53bd0d273146c3a3372d6c8d19a7a"}, "14": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "14.24"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "13"}], "tables": [{"key": "options", "rows": [{"summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/14/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": "-f --force", "source_url": "/docs/14/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/14/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/14/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/14/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/14/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/14/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/14/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/14/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/14/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/14/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/14/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/14/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/14/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "label": "14.24", "major": "14", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/14/postgresql-14-A4.pdf", "bytes": 14354704, "pages": 2944, "sha256": "8bc6b9dd7b246888bb77f0a5e8c39a2eae52e9926569832669c7d1600becb27c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/14/postgresql-14-US.pdf", "bytes": 14242178, "pages": 3102, "sha256": "b7ecb5a5f62d8b9f73a69e25a7d26ba285373bc53168a553bff7b77955506db4", "built_at": "2026-09-26"}}, "tree": "14", "index": "index.html", "major": "14", "pages": 1158, "release": "14.24", "source_url": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae", "evidence_kind": "English manual and source declarations", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "sources": [{"url": "/docs/14/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "14.24 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "cb4f0e87edc1e763699c3e62e9e9e17b6913576111bfd2dee78d5311113df1b8"}, {"url": "/docs/14/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "db0cdccaa8d3c65ad3b2a07d4956eb5a783a18505bfa0f9d9626eef4ab94fe44"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>After running this command, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even if it cannot determine valid data for <code class=\"filename\">pg_control</code>, as explained above.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/14/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for more information.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/14/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "2e75a1fb3e22e5af38c29ab81b14d4bdbfd53bd0d273146c3a3372d6c8d19a7a"}, "15": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "15.19"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "13"}], "tables": [{"key": "options", "rows": [{"summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/15/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": "-f --force", "source_url": "/docs/15/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/15/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/15/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/15/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/15/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/15/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/15/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/15/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/15/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/15/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/15/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/15/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/15/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "label": "15.19", "major": "15", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/15/postgresql-15-A4.pdf", "bytes": 14609140, "pages": 2987, "sha256": "66228564a4d16efb47d6a914085716ecfe22ca1566db56bc7c3d82f790646d72", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/15/postgresql-15-US.pdf", "bytes": 14495690, "pages": 3153, "sha256": "645a498c2390d47a6223ec74770631185807a19c484edb0fc5a295d9f460bc02", "built_at": "2026-09-26"}}, "tree": "15", "index": "index.html", "major": "15", "pages": 1168, "release": "15.19", "source_url": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545", "evidence_kind": "English manual and source declarations", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "sources": [{"url": "/docs/15/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "15.19 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "1c31ec3fe40af133804565a66d8f4f81fc02b72b16b7154553b1f6ffff6486bc"}, {"url": "/docs/15/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "1240cfbb13ebfd22aac8d5ae40c62a9015b246f7774bcf0bce97355ce06350a0"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>After running this command, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even if it cannot determine valid data for <code class=\"filename\">pg_control</code>, as explained above.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/15/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for more information.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/15/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "2e75a1fb3e22e5af38c29ab81b14d4bdbfd53bd0d273146c3a3372d6c8d19a7a"}, "16": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "16.15"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "13"}], "tables": [{"key": "options", "rows": [{"summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/16/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.", "signature": "-f --force", "source_url": "/docs/16/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/16/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/16/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/16/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/16/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/16/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/16/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/16/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/16/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/16/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/16/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/16/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/16/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "label": "16.15", "major": "16", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/16/postgresql-16-A4.pdf", "bytes": 15282337, "pages": 3055, "sha256": "4bb6c1f63deedac98736d8c4c7bc0fad0ac24e85b07e21ee10411872f06afd06", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/16/postgresql-16-US.pdf", "bytes": 15164148, "pages": 3220, "sha256": "5b6b6166c89991199e144bb0ae34c17a5f29826251dbf19db1abc0df3a3e771b", "built_at": "2026-09-26"}}, "tree": "16", "index": "index.html", "major": "16", "pages": 1169, "release": "16.15", "source_url": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef", "evidence_kind": "English manual and source declarations", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "sources": [{"url": "/docs/16/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "16.15 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "780ee88eccc1cd549ae28e5d6f5ee403300d3cd6836febade42cc9c25e33afb9"}, {"url": "/docs/16/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "8aaa4422eece8f26d84715f855d9d0f7f87b200f8b82898c73c865ee42c2c70f"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>After running this command, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even if it cannot determine valid data for <code class=\"filename\">pg_control</code>, as explained above.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/16/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for more information.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/16/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "2e75a1fb3e22e5af38c29ab81b14d4bdbfd53bd0d273146c3a3372d6c8d19a7a"}, "17": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "17.11"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "14"}], "tables": [{"key": "options", "rows": [{"summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "datadir -D datadir --pgdata= datadir"}}, {"summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/17/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": "datadir -D datadir --pgdata= datadir", "source_url": "/docs/17/app-pgresetwal.html", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": "-f --force", "source_url": "/docs/17/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/17/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/17/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/17/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/17/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/17/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/17/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/17/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/17/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/17/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/17/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/17/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/17/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "label": "17.11", "major": "17", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/17/postgresql-17-A4.pdf", "bytes": 15521293, "pages": 3099, "sha256": "1991354df0dc89e70ec39328c28988ef8b19c6a93671dab3893650b63e9f4e36", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/17/postgresql-17-US.pdf", "bytes": 15398150, "pages": 3270, "sha256": "07696c8f38abf31babf22d2db337093936e7c472d2af36d050b000c49bbcf52c", "built_at": "2026-09-26"}}, "tree": "17", "index": "index.html", "major": "17", "pages": 1143, "release": "17.11", "source_url": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487", "evidence_kind": "English manual and source declarations", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "sources": [{"url": "/docs/17/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "17.11 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "ecae222148704f0d9c3112d3aaa5501bee1d4ae49d0b05113753850abfe08852"}, {"url": "/docs/17/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "01f07993ff020684f4c290d17cdafa26fb17ea5c1d476bc3a5efc68bf8ddd9b9"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>Some options, such as <code class=\"option\">--wal-segsize</code> (see below), can also be used to modify certain global settings of a database cluster without the need to rerun <code class=\"command\">initdb</code>. This can be done safely on an otherwise sound database cluster, if none of the dangerous modes mentioned below are used.</p>\n<p>If <code class=\"command\">pg_resetwal</code> is used on a data directory where the server has been cleanly shut down and the control file is sound, then it will have no effect on the contents of the database system, except that no longer used WAL files are cleared away. Any other use is potentially dangerous and must be done with great care. <code class=\"command\">pg_resetwal</code> will require the <code class=\"option\">-f</code> (force) option to be specified before working on a data directory in an unclean shutdown state or with a corrupted control file.</p>\n<p>After running this command on a data directory with corrupted WAL or a corrupted control file, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>datadir</code></em><br></span><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if <code class=\"command\">pg_resetwal</code> cannot determine valid data for <code class=\"filename\">pg_control</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>. Note that these instructions only apply with the standard block size of 8 kB.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/17/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for more information.</p>\n<p>This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re-<code class=\"command\">initdb</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/17/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-D datadir", "--pgdata= datadir"], "signature": "datadir -D datadir --pgdata= datadir", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "db2882d3f20232817113d977ba0fd94c565ea8de3141ad923fb451967d367d18"}, "18": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "18.6"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "15"}], "tables": [{"key": "options", "rows": [{"summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "datadir -D datadir --pgdata= datadir"}}, {"summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}, {"summary": "Manually set the default char signedness. Possible values are signed and unsigned .", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "--char-signedness= option"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": "datadir -D datadir --pgdata= datadir", "source_url": "/docs/18/app-pgresetwal.html", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": "-f --force", "source_url": "/docs/18/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/18/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/18/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/18/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["--char-signedness= option"], "summary": "Manually set the default char signedness. Possible values are signed and unsigned .", "signature": "--char-signedness= option", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the default char signedness. Possible values are signed and unsigned . For a database cluster that pg_upgrade upgraded from a PostgreSQL version before 18, the safe value would be the default char signedness of the platform that ran the cluster before that upgrade. For all other clusters, signed would be the safe value. However, this option is exclusively for use with pg_upgrade and should not normally be used manually."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/18/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "/docs/18/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "18.6 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "d98a541b766cc4c6dd1c5b77d2b20c904ad76b7aa169e8e76916fa724097642f"}, {"url": "/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>Some options, such as <code class=\"option\">--wal-segsize</code> (see below), can also be used to modify certain global settings of a database cluster without the need to rerun <code class=\"command\">initdb</code>. This can be done safely on an otherwise sound database cluster, if none of the dangerous modes mentioned below are used.</p>\n<p>If <code class=\"command\">pg_resetwal</code> is used on a data directory where the server has been cleanly shut down and the control file is sound, then it will have no effect on the contents of the database system, except that no longer used WAL files are cleared away. Any other use is potentially dangerous and must be done with great care. <code class=\"command\">pg_resetwal</code> will require the <code class=\"option\">-f</code> (force) option to be specified before working on a data directory in an unclean shutdown state or with a corrupted control file.</p>\n<p>After running this command on a data directory with corrupted WAL or a corrupted control file, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>datadir</code></em><br></span><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if <code class=\"command\">pg_resetwal</code> cannot determine valid data for <code class=\"filename\">pg_control</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>. Note that these instructions only apply with the standard block size of 8 kB.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--char-signedness=<em class=\"replaceable\"><code>option</code></em></code></span></dt>\n<dd>\n<p>Manually set the default char signedness. Possible values are <code class=\"literal\">signed</code> and <code class=\"literal\">unsigned</code>.</p>\n<p>For a database cluster that <code class=\"command\">pg_upgrade</code> upgraded from a <span class=\"productname\">PostgreSQL</span> version before 18, the safe value would be the default <code class=\"type\">char</code> signedness of the platform that ran the cluster before that upgrade. For all other clusters, <code class=\"literal\">signed</code> would be the safe value. However, this option is exclusively for use with <code class=\"command\">pg_upgrade</code> and should not normally be used manually.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for more information.</p>\n<p>This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re-<code class=\"command\">initdb</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/18/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-D datadir", "--pgdata= datadir"], "signature": "datadir -D datadir --pgdata= datadir", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["--char-signedness= option"], "signature": "--char-signedness= option", "description": "Manually set the default char signedness. Possible values are signed and unsigned . For a database cluster that pg_upgrade upgraded from a PostgreSQL version before 18, the safe value would be the default char signedness of the platform that ran the cluster before that upgrade. For all other clusters, signed would be the safe value. However, this option is exclusively for use with pg_upgrade and should not normally be used manually."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "0f1118258498f92ca5f53e8e85a37fad632ff9873b0fe2ed804994c4a7ed6ca3"}, "19": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "19beta4"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "15"}], "tables": [{"key": "options", "rows": [{"summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "datadir -D datadir --pgdata= datadir"}}, {"summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}, {"summary": "Manually set the default char signedness. Possible values are signed and unsigned .", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "--char-signedness= option"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/19/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": "datadir -D datadir --pgdata= datadir", "source_url": "/docs/19/app-pgresetwal.html", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": "-f --force", "source_url": "/docs/19/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/19/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/19/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/19/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 32768 (0x8000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 32768 (0x8000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 000F and 0007 are the greatest and smallest entries in pg_multixact/offsets , -m 0x80000,0x38000 will work."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["--char-signedness= option"], "summary": "Manually set the default char signedness. Possible values are signed and unsigned .", "signature": "--char-signedness= option", "source_url": "/docs/19/app-pgresetwal.html", "description": "Manually set the default char signedness. Possible values are signed and unsigned . For a database cluster that pg_upgrade upgraded from a PostgreSQL version before 18, the safe value would be the default char signedness of the platform that ran the cluster before that upgrade. For all other clusters, signed would be the safe value. However, this option is exclusively for use with pg_upgrade and should not normally be used manually."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/19/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "label": "19beta4", "major": "19", "channel": "preview", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/19/postgresql-19-A4.pdf", "bytes": 16064841, "pages": 3052, "sha256": "4dd099e4125c591128fc5f3ebd02178dc24781f9e5ae629f96d67c4c8547427b", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/19/postgresql-19-US.pdf", "bytes": 15974616, "pages": 3225, "sha256": "61971fa857f0956d47341a0388fa6af9ae10acf691d4b2fc009007d384b0342b", "built_at": "2026-09-26"}}, "tree": "19", "index": "index.html", "major": "19", "pages": 1155, "release": "19beta4", "source_url": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "svg_assets": 5, "source_mode": "en SGML built with pinned official archive", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "revision": "1bbbbf4133d426f0e4304010688d2984c30fb67df0cc3a61b3e37eb3f6f37833", "evidence_kind": "English manual and source declarations", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "sources": [{"url": "/docs/19/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "19beta4 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "ef961683ce1163fa9c1ecfe89ad6e5349898d754df79e42115e24d31a23e047c"}, {"url": "/docs/19/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "425b070323b448b5516d2cb4e9e4ac77efb5d19dd4e8005d0ae1c61db9ec78e6"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ] <em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>Some options, such as <code class=\"option\">--wal-segsize</code> (see below), can also be used to modify certain global settings of a database cluster without the need to rerun <code class=\"command\">initdb</code>. This can be done safely on an otherwise sound database cluster, if none of the dangerous modes mentioned below are used.</p>\n<p>If <code class=\"command\">pg_resetwal</code> is used on a data directory where the server has been cleanly shut down and the control file is sound, then it will have no effect on the contents of the database system, except that no longer used WAL files are cleared away. Any other use is potentially dangerous and must be done with great care. <code class=\"command\">pg_resetwal</code> will require the <code class=\"option\">-f</code> (force) option to be specified before working on a data directory in an unclean shutdown state or with a corrupted control file.</p>\n<p>After running this command on a data directory with corrupted WAL or a corrupted control file, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>datadir</code></em><br></span><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if <code class=\"command\">pg_resetwal</code> cannot determine valid data for <code class=\"filename\">pg_control</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>. Note that these instructions only apply with the standard block size of 8 kB.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 32768 (0x8000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 32768 (0x8000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">000F</code> and <code class=\"filename\">0007</code> are the greatest and smallest entries in <code class=\"filename\">pg_multixact/offsets</code>, <code class=\"literal\">-m 0x80000,0x38000</code> will work.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--char-signedness=<em class=\"replaceable\"><code>option</code></em></code></span></dt>\n<dd>\n<p>Manually set the default char signedness. Possible values are <code class=\"literal\">signed</code> and <code class=\"literal\">unsigned</code>.</p>\n<p>For a database cluster that <code class=\"command\">pg_upgrade</code> upgraded from a <span class=\"productname\">PostgreSQL</span> version before 18, the safe value would be the default <code class=\"type\">char</code> signedness of the platform that ran the cluster before that upgrade. For all other clusters, <code class=\"literal\">signed</code> would be the safe value. However, this option is exclusively for use with <code class=\"command\">pg_upgrade</code> and should not normally be used manually.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/19/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for more information.</p>\n<p>This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re-<code class=\"command\">initdb</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/19/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-D datadir", "--pgdata= datadir"], "signature": "datadir -D datadir --pgdata= datadir", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 32768 (0x8000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 32768 (0x8000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 000F and 0007 are the greatest and smallest entries in pg_multixact/offsets , -m 0x80000,0x38000 will work."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["--char-signedness= option"], "signature": "--char-signedness= option", "description": "Manually set the default char signedness. Possible values are signed and unsigned . For a database cluster that pg_upgrade upgraded from a PostgreSQL version before 18, the safe value would be the default char signedness of the platform that ran the cluster before that upgrade. For all other clusters, signed would be the safe value. However, this option is exclusively for use with pg_upgrade and should not normally be used manually."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "34fd5dc3fb5ebf7b538a75ff93a05c017170002906782b9bd1f4f77eacc93725"}, "20": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "20devel"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "15"}], "tables": [{"key": "options", "rows": [{"summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "datadir -D datadir --pgdata= datadir"}}, {"summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID (8 bytes).", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-o oid8 --next-oid= oid8"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}, {"summary": "Manually set the default char signedness. Possible values are signed and unsigned .", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "--char-signedness= option"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/devel/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": "datadir -D datadir --pgdata= datadir", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": "-f --force", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/devel/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 32768 (0x8000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 32768 (0x8000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 000F and 0007 are the greatest and smallest entries in pg_multixact/offsets , -m 0x80000,0x38000 will work."}, {"names": ["-o oid8", "--next-oid= oid8"], "summary": "Manually set the next OID (8 bytes).", "signature": "-o oid8 --next-oid= oid8", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the next OID (8 bytes). There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right, as long as the counter is not moved backwards. The counter is 8 bytes wide and never wraps around during the life of a cluster."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["--char-signedness= option"], "summary": "Manually set the default char signedness. Possible values are signed and unsigned .", "signature": "--char-signedness= option", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Manually set the default char signedness. Possible values are signed and unsigned . For a database cluster that pg_upgrade upgraded from a PostgreSQL version before 18, the safe value would be the default char signedness of the platform that ran the cluster before that upgrade. For all other clusters, signed would be the safe value. However, this option is exclusively for use with pg_upgrade and should not normally be used manually."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/devel/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "label": "20devel", "major": "20", "channel": "devel", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/20/postgresql-20-A4.pdf", "bytes": 16030631, "pages": 3052, "sha256": "bd5d82c0ce38fc18f92a0447818a91a193a261776bca1c37564bf9a683e177d0", "built_at": "2026-09-28"}, "US": {"url": "/files/documentation/pdf/20/postgresql-20-US.pdf", "bytes": 15936613, "pages": 3223, "sha256": "d97d9e0db479a02f4234b175f50fcad70c3661619afc8d6df9b9437882e3c299", "built_at": "2026-09-28"}}, "tree": "0", "index": "index.html", "major": "20", "pages": 1156, "release": "20devel", "source_url": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "svg_assets": 6, "source_mode": "en SGML built with pinned official archive", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41", "source_snapshot_utc": "26-Sep-2026 20:22"}, "revision": "2eba5e0fd4c3bffb2803247b6cd537878e9d6ee5a6dfbe3c50ece8b421b80918", "evidence_kind": "English manual and source declarations", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41"}, "sources": [{"url": "/docs/devel/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "20devel English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "b32553130424b1cf768feaf4b5eece90c7c5b12ce5f20a5b10a34dd7b2170a2d"}, {"url": "/docs/devel/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "5532c1ebfb8c6f310301be63a28daf0ae212e2a78025bea61a1bdca99e02c43d"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ] <em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>Some options, such as <code class=\"option\">--wal-segsize</code> (see below), can also be used to modify certain global settings of a database cluster without the need to rerun <code class=\"command\">initdb</code>. This can be done safely on an otherwise sound database cluster, if none of the dangerous modes mentioned below are used.</p>\n<p>If <code class=\"command\">pg_resetwal</code> is used on a data directory where the server has been cleanly shut down and the control file is sound, then it will have no effect on the contents of the database system, except that no longer used WAL files are cleared away. Any other use is potentially dangerous and must be done with great care. <code class=\"command\">pg_resetwal</code> will require the <code class=\"option\">-f</code> (force) option to be specified before working on a data directory in an unclean shutdown state or with a corrupted control file.</p>\n<p>After running this command on a data directory with corrupted WAL or a corrupted control file, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>datadir</code></em><br></span><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if <code class=\"command\">pg_resetwal</code> cannot determine valid data for <code class=\"filename\">pg_control</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>. Note that these instructions only apply with the standard block size of 8 kB.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 32768 (0x8000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 32768 (0x8000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">000F</code> and <code class=\"filename\">0007</code> are the greatest and smallest entries in <code class=\"filename\">pg_multixact/offsets</code>, <code class=\"literal\">-m 0x80000,0x38000</code> will work.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid8</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid8</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID (8 bytes).</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right, as long as the counter is not moved backwards. The counter is 8 bytes wide and never wraps around during the life of a cluster.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--char-signedness=<em class=\"replaceable\"><code>option</code></em></code></span></dt>\n<dd>\n<p>Manually set the default char signedness. Possible values are <code class=\"literal\">signed</code> and <code class=\"literal\">unsigned</code>.</p>\n<p>For a database cluster that <code class=\"command\">pg_upgrade</code> upgraded from a <span class=\"productname\">PostgreSQL</span> version before 18, the safe value would be the default <code class=\"type\">char</code> signedness of the platform that ran the cluster before that upgrade. For all other clusters, <code class=\"literal\">signed</code> would be the safe value. However, this option is exclusively for use with <code class=\"command\">pg_upgrade</code> and should not normally be used manually.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/devel/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for more information.</p>\n<p>This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re-<code class=\"command\">initdb</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/devel/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-D datadir", "--pgdata= datadir"], "signature": "datadir -D datadir --pgdata= datadir", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 32768 (0x8000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 32768 (0x8000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 000F and 0007 are the greatest and smallest entries in pg_multixact/offsets , -m 0x80000,0x38000 will work."}, {"names": ["-o oid8", "--next-oid= oid8"], "signature": "-o oid8 --next-oid= oid8", "description": "Manually set the next OID (8 bytes). There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right, as long as the counter is not moved backwards. The counter is 8 bytes wide and never wraps around during the life of a cluster."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["--char-signedness= option"], "signature": "--char-signedness= option", "description": "Manually set the default char signedness. Possible values are signed and unsigned . For a database cluster that pg_upgrade upgraded from a PostgreSQL version before 18, the safe value would be the default char signedness of the platform that ran the cluster before that upgrade. For all other clusters, signed would be the safe value. However, this option is exclusively for use with pg_upgrade and should not normally be used manually."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "7954cbe6f7140f1ae1a6a70c7e57dcb34421b239a8ced4710e5abf93f76193c6"}}}, "snapshot": {"facts": [{"label": "Documented executable", "value": "pg_resetwal"}, {"label": "Executable version", "value": "18.6"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "15"}], "tables": [{"key": "options", "rows": [{"summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "datadir -D datadir --pgdata= datadir"}}, {"summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-f --force"}}, {"summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-n --dry-run"}}, {"summary": "Display version information, then exit.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-V --version"}}, {"summary": "Show help, then exit.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-? --help"}}, {"summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-c xid , xid --commit-timestamp-ids= xid , xid"}}, {"summary": "Manually set the next transaction ID's epoch.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-e xid_epoch --epoch= xid_epoch"}}, {"summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-l walfile --next-wal-file= walfile"}}, {"summary": "Manually set the next and oldest multitransaction ID.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-m mxid , mxid --multixact-ids= mxid , mxid"}}, {"summary": "Manually set the next OID.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-o oid --next-oid= oid"}}, {"summary": "Manually set the next multitransaction offset.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-O mxoff --multixact-offset= mxoff"}}, {"summary": "Manually set the oldest unfrozen transaction ID.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-u xid --oldest-transaction-id= xid"}}, {"summary": "Manually set the next transaction ID.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "-x xid --next-transaction-id= xid"}}, {"summary": "Manually set the default char signedness. Possible values are signed and unsigned .", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "--char-signedness= option"}}, {"summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": {"url": "/docs/18/app-pgresetwal.html", "text": "--wal-segsize= wal_segment_size"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA .", "signature": "datadir -D datadir --pgdata= datadir", "source_url": "/docs/18/app-pgresetwal.html", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "summary": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control .", "signature": "-f --force", "source_url": "/docs/18/app-pgresetwal.html", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "summary": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real.", "signature": "-n --dry-run", "source_url": "/docs/18/app-pgresetwal.html", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/18/app-pgresetwal.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/18/app-pgresetwal.html", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "summary": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.", "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "summary": "Manually set the next transaction ID's epoch.", "signature": "-e xid_epoch --epoch= xid_epoch", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "summary": "Manually set the WAL starting location by specifying the name of the next WAL segment file.", "signature": "-l walfile --next-wal-file= walfile", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "summary": "Manually set the next and oldest multitransaction ID.", "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "summary": "Manually set the next OID.", "signature": "-o oid --next-oid= oid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "summary": "Manually set the next multitransaction offset.", "signature": "-O mxoff --multixact-offset= mxoff", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "summary": "Manually set the oldest unfrozen transaction ID.", "signature": "-u xid --oldest-transaction-id= xid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "summary": "Manually set the next transaction ID.", "signature": "-x xid --next-transaction-id= xid", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["--char-signedness= option"], "summary": "Manually set the default char signedness. Possible values are signed and unsigned .", "signature": "--char-signedness= option", "source_url": "/docs/18/app-pgresetwal.html", "description": "Manually set the default char signedness. Possible values are signed and unsigned . For a database cluster that pg_upgrade upgraded from a PostgreSQL version before 18, the safe value would be the default char signedness of the platform that ran the cluster before that upgrade. For all other clusters, signed would be the safe value. However, this option is exclusively for use with pg_upgrade and should not normally be used manually."}, {"names": ["--wal-segsize= wal_segment_size"], "summary": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information.", "signature": "--wal-segsize= wal_segment_size", "source_url": "/docs/18/app-pgresetwal.html", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "/docs/18/app-pgresetwal.html", "file": "app-pgresetwal.html", "label": "18.6 English manual \u00b7 app-pgresetwal.html", "anchor": "", "sha256": "d98a541b766cc4c6dd1c5b77d2b20c904ad76b7aa169e8e76916fa724097642f"}, {"url": "/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3"}], "sections": [], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "signature": "pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir", "description": ["pg_resetwal \u2014 reset the write-ahead log and other control information of a PostgreSQL database cluster"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGRESETWAL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_resetwal</span></span></h2>\n<p>pg_resetwal \u2014 reset the write-ahead log and other control information of a <span class=\"productname\">PostgreSQL</span> database cluster</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_resetwal</code> [ <code class=\"option\">-f</code> | <code class=\"option\">--force</code> ] [ <code class=\"option\">-n</code> | <code class=\"option\">--dry-run</code> ] [<em class=\"replaceable\"><code>option</code></em>...] [ <code class=\"option\">-D</code> | <code class=\"option\">--pgdata</code> ]<em class=\"replaceable\"><code>datadir</code></em></p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\">\n<h2>Description</h2>\n<p><code class=\"command\">pg_resetwal</code> clears the write-ahead log (WAL) and optionally resets some other control information stored in the <code class=\"filename\">pg_control</code> file. This function is sometimes needed if these files have become corrupted. It should be used only as a last resort, when the server will not start due to such corruption.</p>\n<p>Some options, such as <code class=\"option\">--wal-segsize</code> (see below), can also be used to modify certain global settings of a database cluster without the need to rerun <code class=\"command\">initdb</code>. This can be done safely on an otherwise sound database cluster, if none of the dangerous modes mentioned below are used.</p>\n<p>If <code class=\"command\">pg_resetwal</code> is used on a data directory where the server has been cleanly shut down and the control file is sound, then it will have no effect on the contents of the database system, except that no longer used WAL files are cleared away. Any other use is potentially dangerous and must be done with great care. <code class=\"command\">pg_resetwal</code> will require the <code class=\"option\">-f</code> (force) option to be specified before working on a data directory in an unclean shutdown state or with a corrupted control file.</p>\n<p>After running this command on a data directory with corrupted WAL or a corrupted control file, it should be possible to start the server, but bear in mind that the database might contain inconsistent data due to partially-committed transactions. You should immediately dump your data, run <code class=\"command\">initdb</code>, and restore. After restore, check for inconsistencies and repair as needed.</p>\n<p>If <code class=\"command\">pg_resetwal</code> complains that it cannot determine valid data for <code class=\"filename\">pg_control</code>, you can force it to proceed anyway by specifying the <code class=\"option\">-f</code> (force) option. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting location fields. These fields can be set using the options discussed below. If you are not able to determine correct values for all these fields, <code class=\"option\">-f</code> can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. <span class=\"emphasis\"><em>Do not</em></span> execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.</p>\n<p>This utility can only be run by the user who installed the server, because it requires read/write access to the data directory.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>datadir</code></em><br></span><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. <code class=\"command\">pg_resetwal</code> does not use the environment variable <code class=\"envar\">PGDATA</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f</code><br></span><span class=\"term\"><code class=\"option\">--force</code></span></dt>\n<dd>\n<p>Force <code class=\"command\">pg_resetwal</code> to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if <code class=\"command\">pg_resetwal</code> cannot determine valid data for <code class=\"filename\">pg_control</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p>The <code class=\"option\">-n</code>/<code class=\"option\">--dry-run</code> option instructs <code class=\"command\">pg_resetwal</code> to print the values reconstructed from <code class=\"filename\">pg_control</code> and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing <code class=\"command\">pg_resetwal</code> to proceed for real.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Display version information, then exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help, then exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following options are only needed when <code class=\"command\">pg_resetwal</code> is unable to determine appropriate values by reading <code class=\"filename\">pg_control</code>. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix <code class=\"literal\">0x</code>. Note that these instructions only apply with the standard block size of 8 kB.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c <em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--commit-timestamp-ids=<em class=\"replaceable\"><code>xid</code></em>,<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest and newest transaction IDs for which the commit time can be retrieved.</p>\n<p>A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_commit_ts</code> under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>xid_epoch</code></em></code><br></span><span class=\"term\"><code class=\"option\">--epoch=<em class=\"replaceable\"><code>xid_epoch</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID's epoch.</p>\n<p>The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by <code class=\"command\">pg_resetwal</code>, so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as <span class=\"application\">Slony-I</span> and <span class=\"application\">Skytools</span> work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>walfile</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-wal-file=<em class=\"replaceable\"><code>walfile</code></em></code></span></dt>\n<dd>\n<p>Manually set the WAL starting location by specifying the name of the next WAL segment file.</p>\n<p>The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory <code class=\"filename\">pg_wal</code> under the data directory. These names are also in hexadecimal and have three parts. The first part is the <span class=\"quote\">\u201c<span class=\"quote\">timeline ID</span>\u201d</span> and should usually be kept the same. For example, if <code class=\"filename\">00000001000000320000004A</code> is the largest entry in <code class=\"filename\">pg_wal</code>, use <code class=\"literal\">-l 00000001000000320000004B</code> or higher.</p>\n<p>Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><code class=\"command\">pg_resetwal</code> itself looks at the files in <code class=\"filename\">pg_wal</code> and chooses a default <code class=\"option\">-l</code> setting beyond the last existing file name. Therefore, manual adjustment of <code class=\"option\">-l</code> should only be needed if you are aware of WAL segment files that are not currently present in <code class=\"filename\">pg_wal</code>, such as entries in an offline archive; or if the contents of <code class=\"filename\">pg_wal</code> have been lost entirely.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-ids=<em class=\"replaceable\"><code>mxid</code></em>,<em class=\"replaceable\"><code>mxid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next and oldest multitransaction ID.</p>\n<p>A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/offsets</code> under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of <code class=\"option\">-m</code>) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>oid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-oid=<em class=\"replaceable\"><code>oid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next OID.</p>\n<p>There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O <em class=\"replaceable\"><code>mxoff</code></em></code><br></span><span class=\"term\"><code class=\"option\">--multixact-offset=<em class=\"replaceable\"><code>mxoff</code></em></code></span></dt>\n<dd>\n<p>Manually set the next multitransaction offset.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_multixact/members</code> under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-u <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--oldest-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the oldest unfrozen transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically smallest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0007</code> is the smallest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-u 0x700000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x <em class=\"replaceable\"><code>xid</code></em></code><br></span><span class=\"term\"><code class=\"option\">--next-transaction-id=<em class=\"replaceable\"><code>xid</code></em></code></span></dt>\n<dd>\n<p>Manually set the next transaction ID.</p>\n<p>A safe value can be determined by looking for the numerically largest file name in the directory <code class=\"filename\">pg_xact</code> under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if <code class=\"filename\">0011</code> is the largest entry in <code class=\"filename\">pg_xact</code>, <code class=\"literal\">-x 0x1200000</code> will work (five trailing zeroes provide the proper multiplier).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--char-signedness=<em class=\"replaceable\"><code>option</code></em></code></span></dt>\n<dd>\n<p>Manually set the default char signedness. Possible values are <code class=\"literal\">signed</code> and <code class=\"literal\">unsigned</code>.</p>\n<p>For a database cluster that <code class=\"command\">pg_upgrade</code> upgraded from a <span class=\"productname\">PostgreSQL</span> version before 18, the safe value would be the default <code class=\"type\">char</code> signedness of the platform that ran the cluster before that upgrade. For all other clusters, <code class=\"literal\">signed</code> would be the safe value. However, this option is exclusively for use with <code class=\"command\">pg_upgrade</code> and should not normally be used manually.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--wal-segsize=<em class=\"replaceable\"><code>wal_segment_size</code></em></code></span></dt>\n<dd>\n<p>Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of <a class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for more information.</p>\n<p>This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re-<code class=\"command\">initdb</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>While <code class=\"command\">pg_resetwal</code> will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use <code class=\"option\">-l</code> together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.</p>\n</div>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2>Notes</h2>\n<p>This command must not be used when the server is running. <code class=\"command\">pg_resetwal</code> will refuse to start up if it finds a server lock file in the data directory. If the server crashed then a lock file might have been left behind; in that case you can remove the lock file to allow <code class=\"command\">pg_resetwal</code> to run. But before you do so, make doubly certain that there is no server process still alive.</p>\n<p><code class=\"command\">pg_resetwal</code> works only with servers of the same major version.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.9\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/18/app-pgcontroldata.html\" title=\"pg_controldata\"><span class=\"refentrytitle\"><span class=\"application\">pg_controldata</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgresetwal.html", "comparison_data": {"options": [{"names": ["-D datadir", "--pgdata= datadir"], "signature": "datadir -D datadir --pgdata= datadir", "description": "Specifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. pg_resetwal does not use the environment variable PGDATA ."}, {"names": ["-f", "--force"], "signature": "-f --force", "description": "Force pg_resetwal to proceed even in situations where it could be dangerous, as explained above. Specifically, this option is required to proceed if the server had not been cleanly shut down or if pg_resetwal cannot determine valid data for pg_control ."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "The -n / --dry-run option instructs pg_resetwal to print the values reconstructed from pg_control and values about to be changed, and then exit without modifying anything. This is mainly a debugging tool, but can be useful as a sanity check before allowing pg_resetwal to proceed for real."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}, {"names": ["-c xid , xid", "--commit-timestamp-ids= xid , xid"], "signature": "-c xid , xid --commit-timestamp-ids= xid , xid", "description": "Manually set the oldest and newest transaction IDs for which the commit time can be retrieved. A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory pg_commit_ts under the data directory. Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically greatest file name in the same directory. The file names are in hexadecimal."}, {"names": ["-e xid_epoch", "--epoch= xid_epoch"], "signature": "-e xid_epoch --epoch= xid_epoch", "description": "Manually set the next transaction ID's epoch. The transaction ID epoch is not actually stored anywhere in the database except in the field that is set by pg_resetwal , so any value will work so far as the database itself is concerned. You might need to adjust this value to ensure that replication systems such as Slony-I and Skytools work correctly \u2014 if so, an appropriate value should be obtainable from the state of the downstream replicated database."}, {"names": ["-l walfile", "--next-wal-file= walfile"], "signature": "-l walfile --next-wal-file= walfile", "description": "Manually set the WAL starting location by specifying the name of the next WAL segment file. The name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory pg_wal under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u201c timeline ID \u201d and should usually be kept the same. For example, if 00000001000000320000004A is the largest entry in pg_wal , use -l 00000001000000320000004B or higher. Note that when using nondefault WAL segment sizes, the numbers in the WAL file names are different from the LSNs that are reported by system functions and system views. This option takes a WAL file name, not an LSN. Note pg_resetwal itself looks at the files in pg_wal and chooses a default -l setting beyond the last existing file name. Therefore, manual adjustment of -l should only be needed if you are aware of WAL segment files that are not currently present in pg_wal , such as entries in an offline archive; or if the contents of pg_wal have been lost entirely."}, {"names": ["-m mxid , mxid", "--multixact-ids= mxid , mxid"], "signature": "-m mxid , mxid --multixact-ids= mxid , mxid", "description": "Manually set the next and oldest multitransaction ID. A safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory pg_multixact/offsets under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of -m ) can be determined by looking for the numerically smallest file name in the same directory and multiplying by 65536. The file names are in hexadecimal, so the easiest way to do this is to specify the option value in hexadecimal and append four zeroes."}, {"names": ["-o oid", "--next-oid= oid"], "signature": "-o oid --next-oid= oid", "description": "Manually set the next OID. There is no comparably easy way to determine a next OID that's beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right."}, {"names": ["-O mxoff", "--multixact-offset= mxoff"], "signature": "-O mxoff --multixact-offset= mxoff", "description": "Manually set the next multitransaction offset. A safe value can be determined by looking for the numerically largest file name in the directory pg_multixact/members under the data directory, adding one, and then multiplying by 52352 (0xCC80). The file names are in hexadecimal. There is no simple recipe such as the ones for other options of appending zeroes."}, {"names": ["-u xid", "--oldest-transaction-id= xid"], "signature": "-u xid --oldest-transaction-id= xid", "description": "Manually set the oldest unfrozen transaction ID. A safe value can be determined by looking for the numerically smallest file name in the directory pg_xact under the data directory and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0007 is the smallest entry in pg_xact , -u 0x700000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["-x xid", "--next-transaction-id= xid"], "signature": "-x xid --next-transaction-id= xid", "description": "Manually set the next transaction ID. A safe value can be determined by looking for the numerically largest file name in the directory pg_xact under the data directory, adding one, and then multiplying by 1048576 (0x100000). Note that the file names are in hexadecimal. It is usually easiest to specify the option value in hexadecimal too. For example, if 0011 is the largest entry in pg_xact , -x 0x1200000 will work (five trailing zeroes provide the proper multiplier)."}, {"names": ["--char-signedness= option"], "signature": "--char-signedness= option", "description": "Manually set the default char signedness. Possible values are signed and unsigned . For a database cluster that pg_upgrade upgraded from a PostgreSQL version before 18, the safe value would be the default char signedness of the platform that ran the cluster before that upgrade. For all other clusters, signed would be the safe value. However, this option is exclusively for use with pg_upgrade and should not normally be used manually."}, {"names": ["--wal-segsize= wal_segment_size"], "signature": "--wal-segsize= wal_segment_size", "description": "Set the new WAL segment size, in megabytes. The value must be set to a power of 2 between 1 and 1024 (megabytes). See the same option of initdb for more information. This option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re- initdb . Note While pg_resetwal will set the WAL starting address beyond the latest existing WAL segment file, some segment size changes can cause previous WAL file names to be reused. It is recommended to use -l together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy."}], "synopsis": ["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"], "environment": [{"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "0f1118258498f92ca5f53e8e85a37fad632ff9873b0fe2ed804994c4a7ed6ca3"}, "comparison": {"left": "11", "right": "12", "status": "changed", "diff": "--- PostgreSQL 11\n+++ PostgreSQL 12\n@@ -1,5 +1,10 @@\n {\n-  \"environment\": [],\n+  \"environment\": [\n+    {\n+      \"description\": \"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .\",\n+      \"name\": \"PG_COLOR\"\n+    }\n+  ],\n   \"options\": [\n     {\n       \"description\": \"Force pg_resetwal to proceed even if it cannot determine valid data for pg_control , as explained above.\","}}