{"Entry":{"collection":"tool","key":"pg-resetwal","name":"pg_resetwal","aliases":["pg_resetwal"],"metadata":{"aliases":["pg_resetwal"],"category":"Server applications","content_hash":"7d3e088ec3d8c979a26639759d6cd56e87f8c986b8e8298904fa773a00cec5e1","derived_content_hash":"4b075a341f55a18f80860ff7baf09ffc3d98376c23f3cfe819bdab7bd5920857","imported_at":"2026-09-30T00:40:34.346137+08:00","name":"pg_resetwal","name_zh":"","slug":"pg-resetwal","summary":"pg_resetwal — reset the write-ahead log and other control information of a PostgreSQL database cluster"}},"Definition":{"Collection":"tool","Key":"pg-resetwal","SourceDatabase":"center","Version":"18","SourceTable":"command_tool","SourceKey":"pg-resetwal","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"environment":[{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"}],"options":[{"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":["-D datadir","--pgdata= datadir"],"signature":"datadir -D datadir --pgdata= datadir"},{"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":["-f","--force"],"signature":"-f --force"},{"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":["-n","--dry-run"],"signature":"-n --dry-run"},{"description":"Display version information, then exit.","names":["-V","--version"],"signature":"-V --version"},{"description":"Show help, then exit.","names":["-?","--help"],"signature":"-? --help"},{"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":["-c xid , xid","--commit-timestamp-ids= xid , xid"],"signature":"-c xid , xid --commit-timestamp-ids= xid , xid"},{"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 — if so, an appropriate value should be obtainable from the state of the downstream replicated database.","names":["-e xid_epoch","--epoch= xid_epoch"],"signature":"-e xid_epoch --epoch= xid_epoch"},{"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 “ timeline ID ” 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":["-l walfile","--next-wal-file= walfile"],"signature":"-l walfile --next-wal-file= walfile"},{"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":["-m mxid , mxid","--multixact-ids= mxid , mxid"],"signature":"-m mxid , mxid --multixact-ids= mxid , mxid"},{"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 oid","--next-oid= oid"],"signature":"-o oid --next-oid= oid"},{"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":["-O mxoff","--multixact-offset= mxoff"],"signature":"-O mxoff --multixact-offset= mxoff"},{"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":["-u xid","--oldest-transaction-id= xid"],"signature":"-u xid --oldest-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":["-x xid","--next-transaction-id= xid"],"signature":"-x xid --next-transaction-id= xid"},{"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":["--char-signedness= option"],"signature":"--char-signedness= option"},{"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":["--wal-segsize= wal_segment_size"],"signature":"--wal-segsize= wal_segment_size"}],"synopsis":["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"]},"comparison_hash":"0f1118258498f92ca5f53e8e85a37fad632ff9873b0fe2ed804994c4a7ed6ca3","description":["pg_resetwal — reset the write-ahead log and other control information of a PostgreSQL database cluster"],"description_zh":"描述 pg_resetwal 会清除预写式日志（WAL），并可选择性地重置存储在 pg_control 文件中的某些其他控制信息。如果这些文件已经损坏，有时就需要使用此功能。只有当服务器因这类损坏而无法启动时，才应将其作为最后手段使用。 某些选项，如 --wal-segsize （见下文），也可用于在不重新运行 initdb 的情况下修改数据库集簇的某些全局设置。若不使用下文提到的危险模式，则可在其他方面完好的数据库集簇上安全执行此操作。 如果在某个数据目录上使用 pg_resetwal 时，服务器已经被干净关闭且控制文件完好，那么除了会清除不再使用的 WAL 文件外，它不会对数据库系统的内容产生任何影响。其他任何用法都可能有危险，必须极其谨慎。若要在服务器未干净关闭或控制文件已损坏的数据目录上执行操作， pg_resetwal 要求必须指定 -f （强制）选项。 在带有损坏 WAL 或损坏控制文件的数据目录上运行此命令后，服务器应该可以启动；但请记住，由于仅部分提交的事务，数据库中可能含有不一致的数据。应立即转储数据，运行 initdb ，然后恢复。恢复后，请检查是否存在不一致并按需修复。 如果 pg_resetwal 报告无法确定 pg_control 的有效数据，则可以通过指定 -f （强制）选项强行继续。在这种情况下，缺失的数据将以看似合理的值代替。大多数字段预计都能匹配，但对于下一个 OID、下一个事务 ID 及其纪元、下一个多事务 ID 及其偏移量，以及 WAL 起始位置字段，可能仍需要人工协助。这些字段可通过下文讨论的选项来设置。如果无法为所有这些字段确定正确值，仍然可以使用 -f ，但恢复得到的数据库必须比平时更受怀疑：立即转储并恢复势在必行。 切勿 在完成转储之前对数据库执行任何修改数据的操作，因为任何此类操作都很可能使损坏进一步恶化。 该工具只能由安装该服务器的用户运行，因为它需要对数据目录具有读写访问权限。 选项 datadir -D datadir --pgdata= datadir 指定数据库目录的位置。出于安全原因，必须在命令行上指定数据目录","description_zh_html":"\u003cp\u003e命令行工具 pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir。\u003c/p\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cdiv class=\"refsect1\"\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 会清除预写式日志（WAL），并可选择性地重置存储在\n   \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e 文件中的某些其他控制信息。如果这些文件已经损坏，有时就需要使用此功能。只有当服务器因这类损坏而无法启动时，才应将其作为最后手段使用。\n  \u003c/p\u003e\u003cp\u003e\n   某些选项，如 \u003ccode class=\"option\"\u003e--wal-segsize\u003c/code\u003e（见下文），也可用于在不重新运行\n   \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 的情况下修改数据库集簇的某些全局设置。若不使用下文提到的危险模式，则可在其他方面完好的数据库集簇上安全执行此操作。\n  \u003c/p\u003e\u003cp\u003e\n   如果在某个数据目录上使用 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 时，服务器已经被干净关闭且控制文件完好，那么除了会清除不再使用的 WAL 文件外，它不会对数据库系统的内容产生任何影响。其他任何用法都可能有危险，必须极其谨慎。若要在服务器未干净关闭或控制文件已损坏的数据目录上执行操作，\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 要求必须指定 \u003ccode class=\"option\"\u003e-f\u003c/code\u003e（强制）选项。\n  \u003c/p\u003e\u003cp\u003e\n   在带有损坏 WAL 或损坏控制文件的数据目录上运行此命令后，服务器应该可以启动；但请记住，由于仅部分提交的事务，数据库中可能含有不一致的数据。应立即转储数据，运行 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e，然后恢复。恢复后，请检查是否存在不一致并按需修复。\n  \u003c/p\u003e\u003cp\u003e\n   如果 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 报告无法确定 \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e 的有效数据，则可以通过指定 \u003ccode class=\"option\"\u003e-f\u003c/code\u003e（强制）选项强行继续。在这种情况下，缺失的数据将以看似合理的值代替。大多数字段预计都能匹配，但对于下一个 OID、下一个事务 ID 及其纪元、下一个多事务 ID\n   及其偏移量，以及 WAL 起始位置字段，可能仍需要人工协助。这些字段可通过下文讨论的选项来设置。如果无法为所有这些字段确定正确值，仍然可以使用 \u003ccode class=\"option\"\u003e-f\u003c/code\u003e，但恢复得到的数据库必须比平时更受怀疑：立即转储并恢复势在必行。\u003cspan class=\"emphasis\"\u003e\u003cem\u003e切勿\u003c/em\u003e\u003c/span\u003e在完成转储之前对数据库执行任何修改数据的操作，因为任何此类操作都很可能使损坏进一步恶化。\n  \u003c/p\u003e\u003cp\u003e\n   该工具只能由安装该服务器的用户运行，因为它需要对数据目录具有读写访问权限。\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\"\u003e\u003ch2\u003e选项\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      指定数据库目录的位置。出于安全原因，必须在命令行上指定数据目录。\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 不使用环境变量 \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--force\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      即使在可能有危险的情况下，也强制 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 继续执行，如上文所述。具体来说，如果服务器未被干净关闭，或者 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 无法为\n      \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e 确定有效数据，则必须指定该选项。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dry-run\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n\u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--dry-run\u003c/code\u003e 选项会让 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e\n      打印从 \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e 重建出的值以及即将更改的值，然后在不做任何修改的情况下退出。这主要是调试工具，但在真正允许 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 执行之前，也可用作合理性检查。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e显示版本信息，然后退出。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e显示帮助，然后退出。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n   以下选项仅在 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 无法通过读取 \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e\n   确定适当值时才需要使用。安全值可按下述方法确定。对于接受数字参数的选项，可使用前缀\n   \u003ccode class=\"literal\"\u003e0x\u003c/code\u003e 指定十六进制值。请注意，这些说明仅适用于标准块大小为 8 kB 的情况。\n  \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--commit-timestamp-ids=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      手工设置可检索提交时间的最旧和最新事务 ID。\n     \u003c/p\u003e\u003cp\u003e\n      可检索提交时间的最旧事务 ID 的安全值（第一部分），可以通过查看数据目录下\n      \u003ccode class=\"filename\"\u003epg_commit_ts\u003c/code\u003e 目录中数值最小的文件名来确定。相反，可检索提交时间的最新事务 ID 的安全值（第二部分），可以通过查看同一目录中数值最大的文件名来确定。文件名均为十六进制。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid_epoch\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--epoch=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid_epoch\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      手工设置下一个事务 ID 的纪元。\n     \u003c/p\u003e\u003cp\u003e\n      事务 ID 纪元实际上并未存储在数据库中的任何地方，除了由 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e\n      设置的这个字段，因此就数据库本身而言，任何值都可用。可能需要调整该值，以确保\n      \u003cspan class=\"application\"\u003eSlony-I\u003c/span\u003e 和 \u003cspan class=\"application\"\u003eSkytools\u003c/span\u003e 等复制系统正常工作 — 如果确有需要，应该可以从下游复制数据库的状态中获得合适的值。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l \u003cem class=\"replaceable\"\u003e\u003ccode\u003ewalfile\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-wal-file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ewalfile\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      通过指定下一个 WAL 段文件的名称，手工设置 WAL 起始位置。\n     \u003c/p\u003e\u003cp\u003e\n      下一个 WAL 段文件的名称应大于当前数据目录下 \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e 目录中现存的任意\n      WAL 段文件名。这些名称同样采用十六进制，并由三个部分组成。第一部分是\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e时间线 ID\u003c/span\u003e”\u003c/span\u003e，通常应保持不变。例如，如果 \u003ccode class=\"filename\"\u003e00000001000000320000004A\u003c/code\u003e 是\n      \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e 中最大的条目，则应使用\n      \u003ccode class=\"literal\"\u003e-l 00000001000000320000004B\u003c/code\u003e 或更大的值。\n     \u003c/p\u003e\u003cp\u003e\n      请注意，在使用非默认 WAL 段大小时，WAL 文件名中的数字与系统函数和系统视图报告的 LSN 不同。该选项接受的是 WAL 文件名，而不是 LSN。\n     \u003c/p\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003e注意\u003c/h3\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 本身会查看 \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e 中的文件，并选择一个超出现有最后一个文件名的默认 \u003ccode class=\"option\"\u003e-l\u003c/code\u003e 设置。因此，只有在明确知道存在当前不在\n       \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e 中的 WAL 段文件（例如离线归档中的条目），或者\n       \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e 的内容已经完全丢失时，才需要手工调整 \u003ccode class=\"option\"\u003e-l\u003c/code\u003e。\n      \u003c/p\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-m \u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--multixact-ids=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      手工设置下一个和最旧的多事务 ID。\n     \u003c/p\u003e\u003cp\u003e\n      下一个多事务 ID 的安全值（第一部分）可以通过查看数据目录下\n      \u003ccode class=\"filename\"\u003epg_multixact/offsets\u003c/code\u003e 目录中数值最大的文件名，先加一，再乘以\n      65536 (0x10000) 来确定。相反，最旧的多事务 ID 的安全值（\u003ccode class=\"option\"\u003e-m\u003c/code\u003e 的第二部分）可以通过查看同一目录中数值最小的文件名并乘以 65536 来确定。文件名为十六进制，因此最简单的做法通常是用十六进制指定选项值，并在后面追加四个零。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-oid=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      手工设置下一个 OID。\n     \u003c/p\u003e\u003cp\u003e\n      并没有同样简单的方法来确定一个超出数据库中最大 OID 的下一个 OID，不过幸运的是，下一个 OID\n      的设置是否精确并不关键。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-O \u003cem class=\"replaceable\"\u003e\u003ccode\u003emxoff\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--multixact-offset=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxoff\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      手工设置下一个多事务偏移量。\n     \u003c/p\u003e\u003cp\u003e\n      安全值可以通过查看数据目录下 \u003ccode class=\"filename\"\u003epg_multixact/members\u003c/code\u003e 目录中数值最大的文件名，先加一，再乘以 52352 (0xCC80) 来确定。文件名是十六进制。这里没有像其他选项那样通过追加零即可得到结果的简单方法。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-u \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--oldest-transaction-id=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      手工设置最旧的未冻结事务 ID。\n     \u003c/p\u003e\u003cp\u003e\n      安全值可以通过查看数据目录下 \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e 目录中数值最小的文件名，再乘以\n      1048576 (0x100000) 来确定。请注意，文件名是十六进制。通常，选项值也用十六进制指定最为简单。例如，如果 \u003ccode class=\"filename\"\u003e0007\u003c/code\u003e 是 \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e 中最小的条目，那么 \u003ccode class=\"literal\"\u003e-u 0x700000\u003c/code\u003e 就可以使用（五个尾随零提供了正确的乘数）。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-x \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-transaction-id=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      手工设置下一个事务 ID。\n     \u003c/p\u003e\u003cp\u003e\n      安全值可以通过查看数据目录下 \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e 目录中数值最大的文件名，先加一，再乘以 1048576 (0x100000) 来确定。请注意，文件名是十六进制。通常，选项值也用十六进制指定最为简单。例如，如果 \u003ccode class=\"filename\"\u003e0011\u003c/code\u003e 是 \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e 中最大的条目，那么 \u003ccode class=\"literal\"\u003e-x 0x1200000\u003c/code\u003e 就可以使用（五个尾随零提供了正确的乘数）。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--char-signedness=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      手工设置默认的 char 有符号性。可选值为 \u003ccode class=\"literal\"\u003esigned\u003c/code\u003e 和\n      \u003ccode class=\"literal\"\u003eunsigned\u003c/code\u003e。\n     \u003c/p\u003e\u003cp\u003e\n      对于由 \u003ccode class=\"command\"\u003epg_upgrade\u003c/code\u003e 从 18 之前的 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e\n      版本升级而来的数据库集簇，安全值应为升级前运行该集簇的平台上默认的 \u003ccode class=\"type\"\u003echar\u003c/code\u003e\n      有符号性。对于所有其他集簇，\u003ccode class=\"literal\"\u003esigned\u003c/code\u003e 就是安全值。不过，该选项专供\n      \u003ccode class=\"command\"\u003epg_upgrade\u003c/code\u003e 使用，通常不应手工使用。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wal-segsize=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ewal_segment_size\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      设置新的 WAL 段大小，单位为兆字节。该值必须是 1 到 1024（兆字节）之间的 2 的幂。更多信息请参见 \u003ca class=\"xref\" href=\"/zh/docs/18/app-initdb.html\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e 中的同名选项。\n     \u003c/p\u003e\u003cp\u003e\n      该选项也可用于更改现有数据库集簇的 WAL 段大小，从而避免重新执行\n      \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e。\n     \u003c/p\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003e注意\u003c/h3\u003e\u003cp\u003e\n       虽然 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 会把 WAL 起始位置设置到超出现有最新 WAL 段文件的位置，但某些段大小变更可能导致旧 WAL 文件名被重新使用。如果 WAL 文件名重叠会给归档策略带来问题，建议将 \u003ccode class=\"option\"\u003e-l\u003c/code\u003e 与此选项配合使用，手工设置 WAL 起始位置。\n      \u003c/p\u003e\u003c/div\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/div\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/app-pgresetwal.html\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","environment":[{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"}],"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"}],"facts_zh":[{"label":"手册中的可执行程序","value":"pg_resetwal"},{"label":"程序版本","value":"18.6"},{"label":"参考清单","value":"服务端程序"},{"label":"选项定义组","value":"15"}],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGRESETWAL\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_resetwal\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_resetwal — reset the write-ahead log and other control information of a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.9.4.1\"\u003e\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e [ \u003ccode class=\"option\"\u003e-f\u003c/code\u003e | \u003ccode class=\"option\"\u003e--force\u003c/code\u003e ] [ \u003ccode class=\"option\"\u003e-n\u003c/code\u003e | \u003ccode class=\"option\"\u003e--dry-run\u003c/code\u003e ] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [ \u003ccode class=\"option\"\u003e-D\u003c/code\u003e | \u003ccode class=\"option\"\u003e--pgdata\u003c/code\u003e ]\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e clears the write-ahead log (WAL) and optionally resets some other control information stored in the \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eSome options, such as \u003ccode class=\"option\"\u003e--wal-segsize\u003c/code\u003e (see below), can also be used to modify certain global settings of a database cluster without the need to rerun \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e. This can be done safely on an otherwise sound database cluster, if none of the dangerous modes mentioned below are used.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 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. \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e will require the \u003ccode class=\"option\"\u003e-f\u003c/code\u003e (force) option to be specified before working on a data directory in an unclean shutdown state or with a corrupted control file.\u003c/p\u003e\n\u003cp\u003eAfter 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 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e, and restore. After restore, check for inconsistencies and repair as needed.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e complains that it cannot determine valid data for \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e, you can force it to proceed anyway by specifying the \u003ccode class=\"option\"\u003e-f\u003c/code\u003e (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, \u003ccode class=\"option\"\u003e-f\u003c/code\u003e can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. \u003cspan class=\"emphasis\"\u003e\u003cem\u003eDo not\u003c/em\u003e\u003c/span\u003e execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.\u003c/p\u003e\n\u003cp\u003eThis utility can only be run by the user who installed the server, because it requires read/write access to the data directory.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.9.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e does not use the environment variable \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--force\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 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 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e cannot determine valid data for \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dry-run\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--dry-run\u003c/code\u003e option instructs \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e to print the values reconstructed from \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e 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 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e to proceed for real.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisplay version information, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following options are only needed when \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e is unable to determine appropriate values by reading \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix \u003ccode class=\"literal\"\u003e0x\u003c/code\u003e. Note that these instructions only apply with the standard block size of 8 kB.\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--commit-timestamp-ids=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the oldest and newest transaction IDs for which the commit time can be retrieved.\u003c/p\u003e\n\u003cp\u003eA 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 \u003ccode class=\"filename\"\u003epg_commit_ts\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid_epoch\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--epoch=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid_epoch\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next transaction ID's epoch.\u003c/p\u003e\n\u003cp\u003eThe transaction ID epoch is not actually stored anywhere in the database except in the field that is set by \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e, 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 \u003cspan class=\"application\"\u003eSlony-I\u003c/span\u003e and \u003cspan class=\"application\"\u003eSkytools\u003c/span\u003e work correctly — if so, an appropriate value should be obtainable from the state of the downstream replicated database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l \u003cem class=\"replaceable\"\u003e\u003ccode\u003ewalfile\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-wal-file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ewalfile\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the WAL starting location by specifying the name of the next WAL segment file.\u003c/p\u003e\n\u003cp\u003eThe name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etimeline ID\u003c/span\u003e”\u003c/span\u003e and should usually be kept the same. For example, if \u003ccode class=\"filename\"\u003e00000001000000320000004A\u003c/code\u003e is the largest entry in \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e, use \u003ccode class=\"literal\"\u003e-l 00000001000000320000004B\u003c/code\u003e or higher.\u003c/p\u003e\n\u003cp\u003eNote 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.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e itself looks at the files in \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e and chooses a default \u003ccode class=\"option\"\u003e-l\u003c/code\u003e setting beyond the last existing file name. Therefore, manual adjustment of \u003ccode class=\"option\"\u003e-l\u003c/code\u003e should only be needed if you are aware of WAL segment files that are not currently present in \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e, such as entries in an offline archive; or if the contents of \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e have been lost entirely.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-m \u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--multixact-ids=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next and oldest multitransaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory \u003ccode class=\"filename\"\u003epg_multixact/offsets\u003c/code\u003e under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of \u003ccode class=\"option\"\u003e-m\u003c/code\u003e) 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-oid=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next OID.\u003c/p\u003e\n\u003cp\u003eThere 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-O \u003cem class=\"replaceable\"\u003e\u003ccode\u003emxoff\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--multixact-offset=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxoff\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next multitransaction offset.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically largest file name in the directory \u003ccode class=\"filename\"\u003epg_multixact/members\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-u \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--oldest-transaction-id=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the oldest unfrozen transaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically smallest file name in the directory \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e 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 \u003ccode class=\"filename\"\u003e0007\u003c/code\u003e is the smallest entry in \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e, \u003ccode class=\"literal\"\u003e-u 0x700000\u003c/code\u003e will work (five trailing zeroes provide the proper multiplier).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-x \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-transaction-id=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next transaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically largest file name in the directory \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e 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 \u003ccode class=\"filename\"\u003e0011\u003c/code\u003e is the largest entry in \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e, \u003ccode class=\"literal\"\u003e-x 0x1200000\u003c/code\u003e will work (five trailing zeroes provide the proper multiplier).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--char-signedness=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the default char signedness. Possible values are \u003ccode class=\"literal\"\u003esigned\u003c/code\u003e and \u003ccode class=\"literal\"\u003eunsigned\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eFor a database cluster that \u003ccode class=\"command\"\u003epg_upgrade\u003c/code\u003e upgraded from a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e version before 18, the safe value would be the default \u003ccode class=\"type\"\u003echar\u003c/code\u003e signedness of the platform that ran the cluster before that upgrade. For all other clusters, \u003ccode class=\"literal\"\u003esigned\u003c/code\u003e would be the safe value. However, this option is exclusively for use with \u003ccode class=\"command\"\u003epg_upgrade\u003c/code\u003e and should not normally be used manually.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wal-segsize=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ewal_segment_size\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet 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 \u003ca class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eThis option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re-\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhile \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 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 \u003ccode class=\"option\"\u003e-l\u003c/code\u003e together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.9.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.9.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eThis command must not be used when the server is running. \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 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 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e to run. But before you do so, make doubly certain that there is no server process still alive.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e works only with servers of the same major version.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.9.9\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgcontroldata.html\" title=\"pg_controldata\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_controldata\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","manual_path":"app-pgresetwal.html","options":[{"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":["-D datadir","--pgdata= datadir"],"signature":"datadir -D datadir --pgdata= datadir","source_url":"/docs/18/app-pgresetwal.html","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 ."},{"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":["-f","--force"],"signature":"-f --force","source_url":"/docs/18/app-pgresetwal.html","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 ."},{"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":["-n","--dry-run"],"signature":"-n --dry-run","source_url":"/docs/18/app-pgresetwal.html","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."},{"description":"Display version information, then exit.","names":["-V","--version"],"signature":"-V --version","source_url":"/docs/18/app-pgresetwal.html","summary":"Display version information, then exit."},{"description":"Show help, then exit.","names":["-?","--help"],"signature":"-? --help","source_url":"/docs/18/app-pgresetwal.html","summary":"Show help, then exit."},{"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":["-c xid , xid","--commit-timestamp-ids= xid , xid"],"signature":"-c xid , xid --commit-timestamp-ids= xid , xid","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the oldest and newest transaction IDs for which the commit time can be retrieved."},{"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 — if so, an appropriate value should be obtainable from the state of the downstream replicated database.","names":["-e xid_epoch","--epoch= xid_epoch"],"signature":"-e xid_epoch --epoch= xid_epoch","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the next transaction ID's epoch."},{"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 “ timeline ID ” 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":["-l walfile","--next-wal-file= walfile"],"signature":"-l walfile --next-wal-file= walfile","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the WAL starting location by specifying the name of the next WAL segment file."},{"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":["-m mxid , mxid","--multixact-ids= mxid , mxid"],"signature":"-m mxid , mxid --multixact-ids= mxid , mxid","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the next and oldest multitransaction ID."},{"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 oid","--next-oid= oid"],"signature":"-o oid --next-oid= oid","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the next OID."},{"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":["-O mxoff","--multixact-offset= mxoff"],"signature":"-O mxoff --multixact-offset= mxoff","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the next multitransaction offset."},{"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":["-u xid","--oldest-transaction-id= xid"],"signature":"-u xid --oldest-transaction-id= xid","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the oldest unfrozen transaction ID."},{"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":["-x xid","--next-transaction-id= xid"],"signature":"-x xid --next-transaction-id= xid","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the next transaction ID."},{"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":["--char-signedness= option"],"signature":"--char-signedness= option","source_url":"/docs/18/app-pgresetwal.html","summary":"Manually set the default char signedness. Possible values are signed and unsigned ."},{"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":["--wal-segsize= wal_segment_size"],"signature":"--wal-segsize= wal_segment_size","source_url":"/docs/18/app-pgresetwal.html","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."}],"related":[],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"sections_zh":[],"signature":"pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir","sources":[{"anchor":"","file":"app-pgresetwal.html","label":"18.6 English manual · app-pgresetwal.html","sha256":"d98a541b766cc4c6dd1c5b77d2b20c904ad76b7aa169e8e76916fa724097642f","url":"/docs/18/app-pgresetwal.html"},{"anchor":"","file":"reference-server.html","label":"Server applications inventory","sha256":"e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3","url":"/docs/18/reference-server.html"}],"synopsis":["pg_resetwal [ -f | --force ] [ -n | --dry-run ] [ option ...] [ -D | --pgdata ] datadir"],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"datadir -D datadir --pgdata= datadir","url":"/docs/18/app-pgresetwal.html"},"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":{"text":"-f --force","url":"/docs/18/app-pgresetwal.html"},"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":{"text":"-n --dry-run","url":"/docs/18/app-pgresetwal.html"},"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":{"text":"-V --version","url":"/docs/18/app-pgresetwal.html"},"summary":"Display version information, then exit."},{"signature":{"text":"-? --help","url":"/docs/18/app-pgresetwal.html"},"summary":"Show help, then exit."},{"signature":{"text":"-c xid , xid --commit-timestamp-ids= xid , xid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the oldest and newest transaction IDs for which the commit time can be retrieved."},{"signature":{"text":"-e xid_epoch --epoch= xid_epoch","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next transaction ID's epoch."},{"signature":{"text":"-l walfile --next-wal-file= walfile","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the WAL starting location by specifying the name of the next WAL segment file."},{"signature":{"text":"-m mxid , mxid --multixact-ids= mxid , mxid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next and oldest multitransaction ID."},{"signature":{"text":"-o oid --next-oid= oid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next OID."},{"signature":{"text":"-O mxoff --multixact-offset= mxoff","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next multitransaction offset."},{"signature":{"text":"-u xid --oldest-transaction-id= xid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the oldest unfrozen transaction ID."},{"signature":{"text":"-x xid --next-transaction-id= xid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next transaction ID."},{"signature":{"text":"--char-signedness= option","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the default char signedness. Possible values are signed and unsigned ."},{"signature":{"text":"--wal-segsize= wal_segment_size","url":"/docs/18/app-pgresetwal.html"},"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."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"}],"title":"Environment variables"}],"tables_zh":[{"columns":[{"key":"signature","label":"选项与参数"},{"key":"summary","label":"说明"}],"key":"options","rows":[{"signature":{"text":"datadir -D datadir --pgdata= datadir","url":"/docs/18/app-pgresetwal.html"},"summary":"指定数据库目录的位置。出于安全原因，必须在命令行上指定数据目录。 pg_resetwal 不使用环境变量 PGDATA 。"},{"signature":{"text":"-f --force","url":"/docs/18/app-pgresetwal.html"},"summary":"即使在可能有危险的情况下，也强制 pg_resetwal 继续执行，如上文所述。具体来说，如果服务器未被干净关闭，或者 pg_resetwal 无法为 pg_control 确定有效数据，则必须指定该选项。"},{"signature":{"text":"-n --dry-run","url":"/docs/18/app-pgresetwal.html"},"summary":"-n / --dry-run 选项会让 pg_resetwal 打印从 pg_control 重建出的值以及即将更改的值，然后在不做任何修改的情况下退出。这主要是调试工具，但在真正允许 pg_resetwal 执行之前，也可用作合理性检查。"},{"signature":{"text":"-V --version","url":"/docs/18/app-pgresetwal.html"},"summary":"显示版本信息，然后退出。"},{"signature":{"text":"-? --help","url":"/docs/18/app-pgresetwal.html"},"summary":"显示帮助，然后退出。"},{"signature":{"text":"-c xid , xid --commit-timestamp-ids= xid , xid","url":"/docs/18/app-pgresetwal.html"},"summary":"手工设置可检索提交时间的最旧和最新事务 ID。"},{"signature":{"text":"-e xid_epoch --epoch= xid_epoch","url":"/docs/18/app-pgresetwal.html"},"summary":"手工设置下一个事务 ID 的纪元。"},{"signature":{"text":"-l walfile --next-wal-file= walfile","url":"/docs/18/app-pgresetwal.html"},"summary":"通过指定下一个 WAL 段文件的名称，手工设置 WAL 起始位置。"},{"signature":{"text":"-m mxid , mxid --multixact-ids= mxid , mxid","url":"/docs/18/app-pgresetwal.html"},"summary":"手工设置下一个和最旧的多事务 ID。"},{"signature":{"text":"-o oid --next-oid= oid","url":"/docs/18/app-pgresetwal.html"},"summary":"手工设置下一个 OID。"},{"signature":{"text":"-O mxoff --multixact-offset= mxoff","url":"/docs/18/app-pgresetwal.html"},"summary":"手工设置下一个多事务偏移量。"},{"signature":{"text":"-u xid --oldest-transaction-id= xid","url":"/docs/18/app-pgresetwal.html"},"summary":"手工设置最旧的未冻结事务 ID。"},{"signature":{"text":"-x xid --next-transaction-id= xid","url":"/docs/18/app-pgresetwal.html"},"summary":"手工设置下一个事务 ID。"},{"signature":{"text":"--char-signedness= option","url":"/docs/18/app-pgresetwal.html"},"summary":"手工设置默认的 char 有符号性。可选值为 signed 和 unsigned 。"},{"signature":{"text":"--wal-segsize= wal_segment_size","url":"/docs/18/app-pgresetwal.html"},"summary":"设置新的 WAL 段大小，单位为兆字节。取值必须是 1 到 1024（兆字节）之间的 2 的幂。更多信息参见 initdb 的同名选项。"}],"title":"手册中的选项"},{"columns":[{"key":"name","label":"变量"},{"key":"description","label":"含义"}],"key":"environment","rows":[{"description":"指定诊断消息是否使用颜色。可选值为 always 、 auto 和 never 。","name":"PG_COLOR"}],"title":"环境变量"}],"zh_from":{"authored_translation":"source-derived-identity","body_sha256":"a545eb95f06c734da95642638e54f29a7594478b9b4f25f434180db465f3a30c","kind":"same-version-chinese-manual-with-source-derived-identity","manual":{"anchor":"","build_id":107,"extraction":"command-description-and-options","fragment_sha256":"dfeeb7bf9037c3f17b747d9f68d6c9b6050a306e3141b65a3b91b39f29871c4e","locale":"zh-Hans","page_key":"app-pgresetwal.html","source_hash":"93af21e861fa5b0120aca49886cda4f51fb31af28ca26383500a6871cfbe3a3c","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/app-pgresetwal.html","version":"18"},"runtime_rerun":false,"source_facts_revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}},"ManualEvidence":{"manual_path":"app-pgresetwal.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"","file":"app-pgresetwal.html","label":"18.6 English manual · app-pgresetwal.html","sha256":"d98a541b766cc4c6dd1c5b77d2b20c904ad76b7aa169e8e76916fa724097642f","url":"/docs/18/app-pgresetwal.html"},{"anchor":"","file":"reference-server.html","label":"Server applications inventory","sha256":"e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3","url":"/docs/18/reference-server.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"tool","Key":"pg-resetwal","SourceDatabase":"center","Version":"18","Locale":"en","Title":"pg_resetwal","Summary":"pg_resetwal — reset the write-ahead log and other control information of a PostgreSQL database cluster","BodyHTML":"\u003cdiv\u003e\u003cdiv id=\"APP-PGRESETWAL\"\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003e\u003cspan\u003e\u003cspan\u003epg_resetwal\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_resetwal — reset the write-ahead log and other control information of a \u003cspan\u003ePostgreSQL\u003c/span\u003e database cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.9.4.1\"\u003e\u003ccode\u003epg_resetwal\u003c/code\u003e [ \u003ccode\u003e-f\u003c/code\u003e | \u003ccode\u003e--force\u003c/code\u003e ] [ \u003ccode\u003e-n\u003c/code\u003e | \u003ccode\u003e--dry-run\u003c/code\u003e ] [\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [ \u003ccode\u003e-D\u003c/code\u003e | \u003ccode\u003e--pgdata\u003c/code\u003e ]\u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"R1-APP-PGRESETWAL-1\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003ccode\u003epg_resetwal\u003c/code\u003e clears the write-ahead log (WAL) and optionally resets some other control information stored in the \u003ccode\u003epg_control\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eSome options, such as \u003ccode\u003e--wal-segsize\u003c/code\u003e (see below), can also be used to modify certain global settings of a database cluster without the need to rerun \u003ccode\u003einitdb\u003c/code\u003e. This can be done safely on an otherwise sound database cluster, if none of the dangerous modes mentioned below are used.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode\u003epg_resetwal\u003c/code\u003e 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. \u003ccode\u003epg_resetwal\u003c/code\u003e will require the \u003ccode\u003e-f\u003c/code\u003e (force) option to be specified before working on a data directory in an unclean shutdown state or with a corrupted control file.\u003c/p\u003e\n\u003cp\u003eAfter 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 \u003ccode\u003einitdb\u003c/code\u003e, and restore. After restore, check for inconsistencies and repair as needed.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode\u003epg_resetwal\u003c/code\u003e complains that it cannot determine valid data for \u003ccode\u003epg_control\u003c/code\u003e, you can force it to proceed anyway by specifying the \u003ccode\u003e-f\u003c/code\u003e (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, \u003ccode\u003e-f\u003c/code\u003e can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. \u003cspan\u003e\u003cem\u003eDo not\u003c/em\u003e\u003c/span\u003e execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.\u003c/p\u003e\n\u003cp\u003eThis utility can only be run by the user who installed the server, because it requires read/write access to the data directory.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.9.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e-D \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--pgdata=\u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. \u003ccode\u003epg_resetwal\u003c/code\u003e does not use the environment variable \u003ccode\u003ePGDATA\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-f\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--force\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003ccode\u003epg_resetwal\u003c/code\u003e 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 \u003ccode\u003epg_resetwal\u003c/code\u003e cannot determine valid data for \u003ccode\u003epg_control\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--dry-run\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003ccode\u003e-n\u003c/code\u003e/\u003ccode\u003e--dry-run\u003c/code\u003e option instructs \u003ccode\u003epg_resetwal\u003c/code\u003e to print the values reconstructed from \u003ccode\u003epg_control\u003c/code\u003e 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 \u003ccode\u003epg_resetwal\u003c/code\u003e to proceed for real.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisplay version information, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following options are only needed when \u003ccode\u003epg_resetwal\u003c/code\u003e is unable to determine appropriate values by reading \u003ccode\u003epg_control\u003c/code\u003e. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix \u003ccode\u003e0x\u003c/code\u003e. Note that these instructions only apply with the standard block size of 8 kB.\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-c \u003cem\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e,\u003cem\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--commit-timestamp-ids=\u003cem\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e,\u003cem\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the oldest and newest transaction IDs for which the commit time can be retrieved.\u003c/p\u003e\n\u003cp\u003eA 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 \u003ccode\u003epg_commit_ts\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-e \u003cem\u003e\u003ccode\u003exid_epoch\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--epoch=\u003cem\u003e\u003ccode\u003exid_epoch\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next transaction ID\u0026#39;s epoch.\u003c/p\u003e\n\u003cp\u003eThe transaction ID epoch is not actually stored anywhere in the database except in the field that is set by \u003ccode\u003epg_resetwal\u003c/code\u003e, 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 \u003cspan\u003eSlony-I\u003c/span\u003e and \u003cspan\u003eSkytools\u003c/span\u003e work correctly — if so, an appropriate value should be obtainable from the state of the downstream replicated database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-l \u003cem\u003e\u003ccode\u003ewalfile\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--next-wal-file=\u003cem\u003e\u003ccode\u003ewalfile\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the WAL starting location by specifying the name of the next WAL segment file.\u003c/p\u003e\n\u003cp\u003eThe name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory \u003ccode\u003epg_wal\u003c/code\u003e under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u003cspan\u003e“\u003cspan\u003etimeline ID\u003c/span\u003e”\u003c/span\u003e and should usually be kept the same. For example, if \u003ccode\u003e00000001000000320000004A\u003c/code\u003e is the largest entry in \u003ccode\u003epg_wal\u003c/code\u003e, use \u003ccode\u003e-l 00000001000000320000004B\u003c/code\u003e or higher.\u003c/p\u003e\n\u003cp\u003eNote 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.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003e\u003ccode\u003epg_resetwal\u003c/code\u003e itself looks at the files in \u003ccode\u003epg_wal\u003c/code\u003e and chooses a default \u003ccode\u003e-l\u003c/code\u003e setting beyond the last existing file name. Therefore, manual adjustment of \u003ccode\u003e-l\u003c/code\u003e should only be needed if you are aware of WAL segment files that are not currently present in \u003ccode\u003epg_wal\u003c/code\u003e, such as entries in an offline archive; or if the contents of \u003ccode\u003epg_wal\u003c/code\u003e have been lost entirely.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-m \u003cem\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e,\u003cem\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--multixact-ids=\u003cem\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e,\u003cem\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next and oldest multitransaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory \u003ccode\u003epg_multixact/offsets\u003c/code\u003e under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of \u003ccode\u003e-m\u003c/code\u003e) 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-o \u003cem\u003e\u003ccode\u003eoid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--next-oid=\u003cem\u003e\u003ccode\u003eoid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next OID.\u003c/p\u003e\n\u003cp\u003eThere is no comparably easy way to determine a next OID that\u0026#39;s beyond the largest one in the database, but fortunately it is not critical to get the next-OID setting right.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-O \u003cem\u003e\u003ccode\u003emxoff\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--multixact-offset=\u003cem\u003e\u003ccode\u003emxoff\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next multitransaction offset.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically largest file name in the directory \u003ccode\u003epg_multixact/members\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-u \u003cem\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--oldest-transaction-id=\u003cem\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the oldest unfrozen transaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically smallest file name in the directory \u003ccode\u003epg_xact\u003c/code\u003e 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 \u003ccode\u003e0007\u003c/code\u003e is the smallest entry in \u003ccode\u003epg_xact\u003c/code\u003e, \u003ccode\u003e-u 0x700000\u003c/code\u003e will work (five trailing zeroes provide the proper multiplier).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-x \u003cem\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--next-transaction-id=\u003cem\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next transaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically largest file name in the directory \u003ccode\u003epg_xact\u003c/code\u003e 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 \u003ccode\u003e0011\u003c/code\u003e is the largest entry in \u003ccode\u003epg_xact\u003c/code\u003e, \u003ccode\u003e-x 0x1200000\u003c/code\u003e will work (five trailing zeroes provide the proper multiplier).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--char-signedness=\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the default char signedness. Possible values are \u003ccode\u003esigned\u003c/code\u003e and \u003ccode\u003eunsigned\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eFor a database cluster that \u003ccode\u003epg_upgrade\u003c/code\u003e upgraded from a \u003cspan\u003ePostgreSQL\u003c/span\u003e version before 18, the safe value would be the default \u003ccode\u003echar\u003c/code\u003e signedness of the platform that ran the cluster before that upgrade. For all other clusters, \u003ccode\u003esigned\u003c/code\u003e would be the safe value. However, this option is exclusively for use with \u003ccode\u003epg_upgrade\u003c/code\u003e and should not normally be used manually.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--wal-segsize=\u003cem\u003e\u003ccode\u003ewal_segment_size\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet 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 \u003ca href=\"/docs/18/app-initdb.html\" title=\"initdb\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eThis option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re-\u003ccode\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhile \u003ccode\u003epg_resetwal\u003c/code\u003e 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 \u003ccode\u003e-l\u003c/code\u003e together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.9.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode\u003ealways\u003c/code\u003e, \u003ccode\u003eauto\u003c/code\u003e and \u003ccode\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.9.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eThis command must not be used when the server is running. \u003ccode\u003epg_resetwal\u003c/code\u003e 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 \u003ccode\u003epg_resetwal\u003c/code\u003e to run. But before you do so, make doubly certain that there is no server process still alive.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epg_resetwal\u003c/code\u003e works only with servers of the same major version.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.9.9\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/docs/18/app-pgcontroldata.html\" title=\"pg_controldata\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_controldata\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"de9fa5dc915eec8c189cb863b6549da5901e4775f3857dd117b84dc95f62da4e","Payload":{"description":["pg_resetwal — reset the write-ahead log and other control information of a PostgreSQL database cluster"],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGRESETWAL\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_resetwal\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_resetwal — reset the write-ahead log and other control information of a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.9.4.1\"\u003e\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e [ \u003ccode class=\"option\"\u003e-f\u003c/code\u003e | \u003ccode class=\"option\"\u003e--force\u003c/code\u003e ] [ \u003ccode class=\"option\"\u003e-n\u003c/code\u003e | \u003ccode class=\"option\"\u003e--dry-run\u003c/code\u003e ] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [ \u003ccode class=\"option\"\u003e-D\u003c/code\u003e | \u003ccode class=\"option\"\u003e--pgdata\u003c/code\u003e ]\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"R1-APP-PGRESETWAL-1\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e clears the write-ahead log (WAL) and optionally resets some other control information stored in the \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eSome options, such as \u003ccode class=\"option\"\u003e--wal-segsize\u003c/code\u003e (see below), can also be used to modify certain global settings of a database cluster without the need to rerun \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e. This can be done safely on an otherwise sound database cluster, if none of the dangerous modes mentioned below are used.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 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. \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e will require the \u003ccode class=\"option\"\u003e-f\u003c/code\u003e (force) option to be specified before working on a data directory in an unclean shutdown state or with a corrupted control file.\u003c/p\u003e\n\u003cp\u003eAfter 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 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e, and restore. After restore, check for inconsistencies and repair as needed.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e complains that it cannot determine valid data for \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e, you can force it to proceed anyway by specifying the \u003ccode class=\"option\"\u003e-f\u003c/code\u003e (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, \u003ccode class=\"option\"\u003e-f\u003c/code\u003e can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and restore is imperative. \u003cspan class=\"emphasis\"\u003e\u003cem\u003eDo not\u003c/em\u003e\u003c/span\u003e execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.\u003c/p\u003e\n\u003cp\u003eThis utility can only be run by the user who installed the server, because it requires read/write access to the data directory.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.9.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the database directory. For safety reasons, you must specify the data directory on the command line. \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e does not use the environment variable \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--force\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 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 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e cannot determine valid data for \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dry-run\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--dry-run\u003c/code\u003e option instructs \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e to print the values reconstructed from \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e 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 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e to proceed for real.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisplay version information, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help, then exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following options are only needed when \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e is unable to determine appropriate values by reading \u003ccode class=\"filename\"\u003epg_control\u003c/code\u003e. Safe values can be determined as described below. For values that take numeric arguments, hexadecimal values can be specified by using the prefix \u003ccode class=\"literal\"\u003e0x\u003c/code\u003e. Note that these instructions only apply with the standard block size of 8 kB.\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--commit-timestamp-ids=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the oldest and newest transaction IDs for which the commit time can be retrieved.\u003c/p\u003e\n\u003cp\u003eA 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 \u003ccode class=\"filename\"\u003epg_commit_ts\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid_epoch\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--epoch=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid_epoch\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next transaction ID's epoch.\u003c/p\u003e\n\u003cp\u003eThe transaction ID epoch is not actually stored anywhere in the database except in the field that is set by \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e, 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 \u003cspan class=\"application\"\u003eSlony-I\u003c/span\u003e and \u003cspan class=\"application\"\u003eSkytools\u003c/span\u003e work correctly — if so, an appropriate value should be obtainable from the state of the downstream replicated database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l \u003cem class=\"replaceable\"\u003e\u003ccode\u003ewalfile\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-wal-file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ewalfile\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the WAL starting location by specifying the name of the next WAL segment file.\u003c/p\u003e\n\u003cp\u003eThe name of next WAL segment file should be larger than any WAL segment file name currently existing in the directory \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e under the data directory. These names are also in hexadecimal and have three parts. The first part is the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etimeline ID\u003c/span\u003e”\u003c/span\u003e and should usually be kept the same. For example, if \u003ccode class=\"filename\"\u003e00000001000000320000004A\u003c/code\u003e is the largest entry in \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e, use \u003ccode class=\"literal\"\u003e-l 00000001000000320000004B\u003c/code\u003e or higher.\u003c/p\u003e\n\u003cp\u003eNote 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.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e itself looks at the files in \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e and chooses a default \u003ccode class=\"option\"\u003e-l\u003c/code\u003e setting beyond the last existing file name. Therefore, manual adjustment of \u003ccode class=\"option\"\u003e-l\u003c/code\u003e should only be needed if you are aware of WAL segment files that are not currently present in \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e, such as entries in an offline archive; or if the contents of \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e have been lost entirely.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-m \u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--multixact-ids=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e,\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next and oldest multitransaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value for the next multitransaction ID (first part) can be determined by looking for the numerically largest file name in the directory \u003ccode class=\"filename\"\u003epg_multixact/offsets\u003c/code\u003e under the data directory, adding one, and then multiplying by 65536 (0x10000). Conversely, a safe value for the oldest multitransaction ID (second part of \u003ccode class=\"option\"\u003e-m\u003c/code\u003e) 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-oid=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next OID.\u003c/p\u003e\n\u003cp\u003eThere 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-O \u003cem class=\"replaceable\"\u003e\u003ccode\u003emxoff\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--multixact-offset=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emxoff\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next multitransaction offset.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically largest file name in the directory \u003ccode class=\"filename\"\u003epg_multixact/members\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-u \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--oldest-transaction-id=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the oldest unfrozen transaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically smallest file name in the directory \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e 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 \u003ccode class=\"filename\"\u003e0007\u003c/code\u003e is the smallest entry in \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e, \u003ccode class=\"literal\"\u003e-u 0x700000\u003c/code\u003e will work (five trailing zeroes provide the proper multiplier).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-x \u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--next-transaction-id=\u003cem class=\"replaceable\"\u003e\u003ccode\u003exid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the next transaction ID.\u003c/p\u003e\n\u003cp\u003eA safe value can be determined by looking for the numerically largest file name in the directory \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e 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 \u003ccode class=\"filename\"\u003e0011\u003c/code\u003e is the largest entry in \u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e, \u003ccode class=\"literal\"\u003e-x 0x1200000\u003c/code\u003e will work (five trailing zeroes provide the proper multiplier).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--char-signedness=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eManually set the default char signedness. Possible values are \u003ccode class=\"literal\"\u003esigned\u003c/code\u003e and \u003ccode class=\"literal\"\u003eunsigned\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eFor a database cluster that \u003ccode class=\"command\"\u003epg_upgrade\u003c/code\u003e upgraded from a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e version before 18, the safe value would be the default \u003ccode class=\"type\"\u003echar\u003c/code\u003e signedness of the platform that ran the cluster before that upgrade. For all other clusters, \u003ccode class=\"literal\"\u003esigned\u003c/code\u003e would be the safe value. However, this option is exclusively for use with \u003ccode class=\"command\"\u003epg_upgrade\u003c/code\u003e and should not normally be used manually.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wal-segsize=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ewal_segment_size\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet 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 \u003ca class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eThis option can also be used to change the WAL segment size of an existing database cluster, avoiding the need to re-\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhile \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 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 \u003ccode class=\"option\"\u003e-l\u003c/code\u003e together with this option to manually set the WAL starting address if WAL file name overlap will cause problems with your archiving strategy.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.9.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.9.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eThis command must not be used when the server is running. \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e 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 \u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e to run. But before you do so, make doubly certain that there is no server process still alive.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003epg_resetwal\u003c/code\u003e works only with servers of the same major version.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.9.9\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgcontroldata.html\" title=\"pg_controldata\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_controldata\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","related":[],"sections":[],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"datadir -D datadir --pgdata= datadir","url":"/docs/18/app-pgresetwal.html"},"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":{"text":"-f --force","url":"/docs/18/app-pgresetwal.html"},"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":{"text":"-n --dry-run","url":"/docs/18/app-pgresetwal.html"},"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":{"text":"-V --version","url":"/docs/18/app-pgresetwal.html"},"summary":"Display version information, then exit."},{"signature":{"text":"-? --help","url":"/docs/18/app-pgresetwal.html"},"summary":"Show help, then exit."},{"signature":{"text":"-c xid , xid --commit-timestamp-ids= xid , xid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the oldest and newest transaction IDs for which the commit time can be retrieved."},{"signature":{"text":"-e xid_epoch --epoch= xid_epoch","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next transaction ID's epoch."},{"signature":{"text":"-l walfile --next-wal-file= walfile","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the WAL starting location by specifying the name of the next WAL segment file."},{"signature":{"text":"-m mxid , mxid --multixact-ids= mxid , mxid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next and oldest multitransaction ID."},{"signature":{"text":"-o oid --next-oid= oid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next OID."},{"signature":{"text":"-O mxoff --multixact-offset= mxoff","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next multitransaction offset."},{"signature":{"text":"-u xid --oldest-transaction-id= xid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the oldest unfrozen transaction ID."},{"signature":{"text":"-x xid --next-transaction-id= xid","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the next transaction ID."},{"signature":{"text":"--char-signedness= option","url":"/docs/18/app-pgresetwal.html"},"summary":"Manually set the default char signedness. Possible values are signed and unsigned ."},{"signature":{"text":"--wal-segsize= wal_segment_size","url":"/docs/18/app-pgresetwal.html"},"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."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"}],"title":"Environment variables"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
