PG throws could not resize shared memory segment error

This is due to the fact that docker by default restricts shared memory size to 64MB which makes pg10 run afoul of this limitation when doing a number of scatter/gather jobs in parallel:

Outside the container:
supermathie@host: ~ $ df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
none             63G  1.2M   63G   1% /run/shm

Inside the container:
supermathie@host: ~ $ docker exec -it postgres-master df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
shm              64M  8.0K   64M   1% /dev/shm

You should raise the limit when launching the postgres container by including the --shm-size=1g parameter.

We’ll look at fixing this in the launcher.

(or as the link suggests, disable parallelism in pg10 with max_parallel_workers_per_gather = 0)

8 Likes