Re:[PATCH]A minor improvement to the error-report in SimpleLruWriteAll()

Поиск
Список
Период
Сортировка
От Long Song
Тема Re:[PATCH]A minor improvement to the error-report in SimpleLruWriteAll()
Дата
Msg-id 5b5d9c66.a708.18fbf20f618.Coremail.songlong88@126.com
обсуждение исходный текст
Ответ на [PATCH]A minor improvement to the error-report in SimpleLruWriteAll()  ("Long Song" <songlong88@126.com>)
Ответы Re: [PATCH]A minor improvement to the error-report in SimpleLruWriteAll()
Список pgsql-hackers
Hi,
Actually, I still wonder why only the error message
of the last failure to close the file was recorded.
For this unusual situation, it is acceptable to
record all failure information without causing
too much logging.
Was it designed that way on purpose?




At 2024-05-25 17:29:00, "Long Song" <songlong88@126.com> wrote:



Hi hackers,
When I read the code, I noticed that in SimpleLruWriteAll(), only the last error is 
recorded when the file fails to close. Like the following,
```void
SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
{
        SlruShared      shared = ctl->shared;
        SlruWriteAllData fdata;
        int64           pageno = 0;
        int                     prevbank = SlotGetBankNumber(0);
        bool            ok;
...
        /*
         * Now close any files that were open
         */
        ok = true;
        for (int i = 0; i < fdata.num_files; i++)
        {
                if (CloseTransientFile(fdata.fd[i]) != 0)
                {
                        slru_errcause = SLRU_CLOSE_FAILED;
                        slru_errno = errno;
                        pageno = fdata.segno[i] * SLRU_PAGES_PER_SEGMENT;
                        ok = false;
                }
        }
        if (!ok)
                SlruReportIOError(ctl, pageno, InvalidTransactionId);
```
// Here, SlruReportIOError() is called only once, meaning that the last error message is
 recorded. In my opinion, since failure to close a file is not common, logging an error 
message every time a failure occurs will not result in much log growth, but detailed error 
logging will help in most cases.

So, I changed the code to move the call to SlruReportIOError() inside the while loop.

Attached is the patch, I hope it can help.





В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: ON ERROR in json_query and the like
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: pgsql: Add more SQL/JSON constructor functions