Fix the error message when failing to restore the snapshot

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Fix the error message when failing to restore the snapshot
Date: 2023-08-22 12:39:09
Message-ID: OS0PR01MB5716D408364F7DF32221C08D941FA@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While testing the logical snapshot restore functionality, I noticed the
data size reported in the error message seems not correct.

I think it's because we used a const value here:

SnapBuildRestoreContents(int fd, char *dest, Size size, const char *path)
...
readBytes = read(fd, dest, size);
pgstat_report_wait_end();
if (readBytes != size)
...
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
errmsg("could not read file \"%s\": read %d of %zu",
** path, readBytes, * sizeof(SnapBuild) *)));

I think we need to pass the size here.

Attach a small patch to fix this. BTW, the error message exists in HEAD ~ PG10.

Best Regards,
Hou zj

Attachment Content-Type Size
0001-Fix-the-error-message-when-failing-to-restore-the-sn.patch application/octet-stream 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-08-22 13:05:15 Re: list of acknowledgments for PG16
Previous Message Chapman Flack 2023-08-22 12:16:02 Re: Extract numeric filed in JSONB more effectively