Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a0edae

Browse files
committed
Fix erroneous error reports in snapbuild.c.
It's pretty unhelpful to report the wrong file name in a complaintabout syscall failure, but SnapBuildSerialize managed to do that twicein a span of 50 lines. Also fix half a dozen missing or poorly-chosenerrcode assignments; that's mostly cosmetic, but still wrong.Noted while studying recent failures on buildfarm member nightjar.I'm not sure whether those reports are actually giving the wrongfilename, because there are two places here with identicallyspelled error messages. The other one is specifically coded notto report ENOENT, but if it's this one, how could we be gettingENOENT from open() with O_CREAT? Need to sit back and await results.However, these ereports are clearly broken from birth, so back-patch.
1 parenta093e14 commit2a0edae

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

‎src/backend/replication/logical/snapbuild.c‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,8 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
15221522

15231523
if (ret!=0&&errno!=ENOENT)
15241524
ereport(ERROR,
1525-
(errmsg("could not stat file \"%s\": %m",path)));
1525+
(errcode_for_file_access(),
1526+
errmsg("could not stat file \"%s\": %m",path)));
15261527

15271528
elseif (ret==0)
15281529
{
@@ -1564,7 +1565,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
15641565
if (unlink(tmppath)!=0&&errno!=ENOENT)
15651566
ereport(ERROR,
15661567
(errcode_for_file_access(),
1567-
errmsg("could not remove file \"%s\": %m",path)));
1568+
errmsg("could not remove file \"%s\": %m",tmppath)));
15681569

15691570
needed_length=sizeof(SnapBuildOnDisk)+
15701571
sizeof(TransactionId)*builder->committed.xcnt;
@@ -1608,7 +1609,8 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
16081609
S_IRUSR |S_IWUSR);
16091610
if (fd<0)
16101611
ereport(ERROR,
1611-
(errmsg("could not open file \"%s\": %m",path)));
1612+
(errcode_for_file_access(),
1613+
errmsg("could not open file \"%s\": %m",tmppath)));
16121614

16131615
errno=0;
16141616
pgstat_report_wait_start(WAIT_EVENT_SNAPBUILD_WRITE);
@@ -1740,12 +1742,14 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn)
17401742

17411743
if (ondisk.magic!=SNAPBUILD_MAGIC)
17421744
ereport(ERROR,
1743-
(errmsg("snapbuild state file \"%s\" has wrong magic number: %u instead of %u",
1745+
(errcode(ERRCODE_DATA_CORRUPTED),
1746+
errmsg("snapbuild state file \"%s\" has wrong magic number: %u instead of %u",
17441747
path,ondisk.magic,SNAPBUILD_MAGIC)));
17451748

17461749
if (ondisk.version!=SNAPBUILD_VERSION)
17471750
ereport(ERROR,
1748-
(errmsg("snapbuild state file \"%s\" has unsupported version: %u instead of %u",
1751+
(errcode(ERRCODE_DATA_CORRUPTED),
1752+
errmsg("snapbuild state file \"%s\" has unsupported version: %u instead of %u",
17491753
path,ondisk.version,SNAPBUILD_VERSION)));
17501754

17511755
INIT_CRC32C(checksum);
@@ -1816,7 +1820,7 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn)
18161820
/* verify checksum of what we've read */
18171821
if (!EQ_CRC32C(checksum,ondisk.checksum))
18181822
ereport(ERROR,
1819-
(errcode_for_file_access(),
1823+
(errcode(ERRCODE_DATA_CORRUPTED),
18201824
errmsg("checksum mismatch for snapbuild state file \"%s\": is %u, should be %u",
18211825
path,checksum,ondisk.checksum)));
18221826

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp