{"Entry":{"collection":"tool","key":"pg-resetwal","name":"pg_resetwal","aliases":["pg_resetwal"],"metadata":{"aliases":["pg_resetwal"],"category":"Server applications","content_hash":"7d3e088ec3d8c979a26639759d6cd56e87f8c986b8e8298904fa773a00cec5e1","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"],"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"}],"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":[],"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"}]},"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":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
