Skip to content

root ownership of pg_stat_tmp causes postgres stats to fail #878

Closed
@EdmundsEcho

Description

@EdmundsEcho

postgres v12 and v13

Thank you for making this official image powerful to work with.

The initialization script changes the ownership of many of the files to postgres (per my superuser), however, it does not include pg_stat and pg_stat_tmp directories where the owner remains root. Is that because these directories are created after the script has executed?

Notwithstanding, the missing permissions seems to be causing the following error:

postgres_db_1   | 2021-09-09 18:06:45.140 UTC [266] WARNING:  could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted

The permissions for the data files:

....
drwx------  2 postgres postgres    68 Sep  9 15:49 pg_replslot
drwx------  2 postgres postgres    68 Sep  9 15:49 pg_serial
drwx------  2 postgres postgres    68 Sep  9 15:49 pg_snapshots
drwx------  2 root     root        68 Sep  9 15:50 pg_stat
drwx------  4 root     root       136 Sep  9 15:50 pg_stat_tmp
...

And the contents of directory mentioned in the error:

root@a8dfd4bbf9f9:/# ls -l /var/lib/postgresql/data/pgdata/pg_stat_tmp
total 40
-rw------- 1 root     root      3014 Sep  9 16:05 db_0.stat
-rw------- 1 root     root     21068 Sep  9 16:05 db_13395.stat
-rw------- 1 postgres postgres  1151 Sep  9 16:05 global.stat

... so able, initially to write to it, but not subsequently access it?

I'm new to working with docker. So, I have not figured out how to run a "patch" at the right point in time i.e., after the files have been created, but before the postgres server fires up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions