hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.07k stars 113 forks source link

bug on pid directory #908

Closed Tiago-Anastacio closed 2 years ago

Tiago-Anastacio commented 2 years ago

Hi Dimitri,

pg_autoctl creates pid files on directory /tmp/pg_autoctl/mylinuxuser this user should be on linux group postgres

first user is pgappli1 (group postgres) second user is pgappli2 (group postgres)

issue: mkdir: cannot create directory ‘/tmp/pg_autoctl/pgappli2’: Permission denied

because first user (e.g. pgappli1) creates : drwxr-xr-x 1 pgappli1 postgres 32 Jun 1 16:34 pg_autoctl

please during creation switch /tmp/pg_autoctl to 775 rather than 755

DimCitus commented 2 years ago

Hi @Tiago-DBA ;

Again, while we could certainly change the privileges, I think there might be a better approach. I just checked and unfortunately that's not documented, which certainly explains why you missed it, that's on me...

In pg_autoctl we use the XDG Base Directory Specification to determine where to store and read our files. See for instance the following source:

https://github.com/citusdata/pg_auto_failover/blob/efcfb73e4a2be4a315a74cf2e1b583cafc85fe0e/src/bin/pg_autoctl/config.c#L243-L266

And then

https://github.com/citusdata/pg_auto_failover/blob/efcfb73e4a2be4a315a74cf2e1b583cafc85fe0e/src/bin/pg_autoctl/config.c#L65-L70

Given that, you can change XDG_RUNTIME_DIR to point to where you want to have the pidfile and other temporary files created for your instance, and maintain different values for different users.

I'm going to leave that issue opened with the following items to solve:

How would you feel about contributing a PR to fix those problems?

Tiago-Anastacio commented 2 years ago

Hi Dimitri, I think just document it should be ok. In case of adding a new parameter: I think naming should be something like RUNTIME_DIR or PID_DIR, because TMPDIR seems to refer to /tmp directory (for someone who's starting with pg_autoctl) Could you translate PR, please ?