From: | "Lin, Cuiping" <lincuiping(at)cn(dot)fujitsu(dot)com> |
---|---|
To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Should program exit, When close() failed for O_RDONLY mode |
Date: | 2020-04-14 02:32:40 |
Message-ID: | 3134406ac1a94ed590347d341ce89e65@G08CNEXMBPEKD05.g08.fujitsu.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I find that most of the code does not check the return value of close(), When open a file for reading(O_RDONLY).
But I find that it checks the return value of close() in code "src/bin/pg_rewind/copy_fetch.c" When open a file for reading(O_RDONLY).
And it will call pg_fatal to cause premature exit.
I think that when closing a read-only file fails, it shouid not exit the program early.It should ensure that the program execution is completed.
Like below:
・src/bin/pg_rewind/copy_fetch.c
before
--------------------------
rewind_copy_file_range
{
...
if (close(srcfd) != 0)
pg_fatal("could not close file \"%s\": %m", srcpath); }
--------------------------
after
--------------------------
rewind_copy_file_range
{
...
close(srcfd);
}
--------------------------
Regards,
--
Lin
From | Date | Subject | |
---|---|---|---|
Next Message | Kyotaro Horiguchi | 2020-04-14 02:35:28 | Re: Corruption during WAL replay |
Previous Message | Michael Paquier | 2020-04-14 02:22:42 | Re: Vacuum o/p with (full 1, parallel 0) option throwing an error |