From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Paul Guo <paulguo(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz> |
Subject: | Re: pg_rewind fails if there is a read only file. |
Date: | 2021-05-19 19:25:55 |
Message-ID: | 3baa19a2-dc08-2612-294c-5f8a18952809@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 5/19/21 6:43 AM, Paul Guo wrote:
> Several weeks ago I saw this issue in a production environment. The
> read only file looks like a credential file. Michael told me that
> usually such kinds of files should be better kept in non-pgdata
> directories in production environments. Thought further it seems that
> pg_rewind should be more user friendly to tolerate such scenarios.
>
> The failure error is "Permission denied" after open(). The reason is
> open() fais with the below mode in open_target_file()
>
> mode = O_WRONLY | O_CREAT | PG_BINARY;
> if (trunc)
> mode |= O_TRUNC;
> dstfd = open(dstpath, mode, pg_file_create_mode);
>
> The fix should be quite simple, if open fails with "Permission denied"
> then we try to call chmod to add a S_IWUSR just before open() and call
> chmod to reset the flags soon after open(). A stat() call to get
> previous st_mode flags is needed.
>
Presumably the user has a reason for adding the file read-only to the
data directory, and we shouldn't lightly ignore that.
Michael's advice is reasonable. This seems like a case of:
Patient: Doctor, it hurts when I do this.
Doctor: Stop doing that.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-05-19 19:35:00 | Re: Commitfest app vs. pgsql-docs |
Previous Message | Justin Pryzby | 2021-05-19 19:16:58 | Re: Removed extra memory allocations from create_list_bounds |