Re: [PATCH] Fix error message in RemoveWalSummaryIfOlderThan to indicate file removal failure - Mailing list pgsql-hackers

From zengman
Subject Re: [PATCH] Fix error message in RemoveWalSummaryIfOlderThan to indicate file removal failure
Date
Msg-id tencent_1CA40FCC21C1C770712BC089@qq.com
Whole thread Raw
In response to Re: [PATCH] Fix error message in RemoveWalSummaryIfOlderThan to indicate file removal failure  (Michael Paquier <michael@paquier.xyz>)
Responses Re: [PATCH] Fix error message in RemoveWalSummaryIfOlderThan to indicate file removal failure
Re: [PATCH] Fix error message in RemoveWalSummaryIfOlderThan to indicate file removal failure
List pgsql-hackers
> Likely so.  This one should be backpatched, as the error generated
> could be confusing if faced.  That's very unlikely so, still..  I'll
> look at other places in the tree for similar inconsistencies, while on
> it.

Hi Michael,

Thank you for helping to address this! I’ve gone back and reviewed the code, and noticed `OpenWalSummaryFile`:
```
File
OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok)
{
    char        path[MAXPGPATH];
    File        file;

    snprintf(path, MAXPGPATH,
             XLOGDIR "/summaries/%08X%08X%08X%08X%08X.summary",
             ws->tli,
             LSN_FORMAT_ARGS(ws->start_lsn),
             LSN_FORMAT_ARGS(ws->end_lsn));

    file = PathNameOpenFile(path, O_RDONLY);
    if (file < 0 && (errno != EEXIST || !missing_ok))
        ereport(ERROR,
                (errcode_for_file_access(),
                 errmsg("could not open file \"%s\": %m", path)));

    return file;
}
```
I’m thinking of changing `errno != EEXIST` to `errno != ENOENT` here — would you think this adjustment is appropriate?

--
Regards,
Man Zeng

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: relkind as an enum
Next
From: Xuneng Zhou
Date:
Subject: Re: Improve read_local_xlog_page_guts by replacing polling with latch-based waiting