pg_resetwal --next-transaction-id may cause database failed to restart.

From: "movead(dot)li(at)highgo(dot)ca" <movead(dot)li(at)highgo(dot)ca>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_resetwal --next-transaction-id may cause database failed to restart.
Date: 2020-06-22 06:31:37
Message-ID: 20200622143134738140105@highgo.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hello hackers,

When I try to use pg_resetwal tool to skip some transaction ID, I get a problem that is
the tool can accept all transaction id I offered with '-x' option, however, the database
may failed to restart because of can not read file under $PGDATA/pg_xact. For
example, the 'NextXID' in a database is 1000, if you offer '-x 32769' then the database
failed to restart.

I read the document of pg_resetwal tool, it told me to write a 'safe value', but I think
pg_resetwal tool should report it and refuse to exec walreset work when using an unsafe
value, rather than remaining it until the user restarts the database.

I do a initial patch to limit the input, now it accepts transaction in two ways:
1. The transaction ID is on the same CLOG page with the 'NextXID' in pg_control.
2. The transaction ID is right at the end of a CLOG page.
The input limited above can ensure the database restart successfully.

The same situation with multixact and multixact-offset option and I make
the same change in the patch.

Do you think it is an issue?

Regards,
Highgo Software (Canada/China/Pakistan)
URL : www.highgo.ca
EMAIL: mailto:movead(dot)li(at)highgo(dot)ca

Attachment Content-Type Size
pg_resetwal_transaction_limit.patch application/octet-stream 3.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2020-06-22 07:15:19 Re: [PATCH] Initial progress reporting for COPY command
Previous Message Amul Sul 2020-06-22 06:29:09 Re: [Patch] ALTER SYSTEM READ ONLY