Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hit by size limit of /dev/shm #416

Closed
otbutz opened this issue Feb 20, 2018 · 5 comments
Closed

Hit by size limit of /dev/shm #416

otbutz opened this issue Feb 20, 2018 · 5 comments
Labels
question Usability question, not directly related to an error with the image Request Request for image modification or feature

Comments

@otbutz
Copy link

otbutz commented Feb 20, 2018

The default limit for Docker containers seems to be 64MB

ERROR:  could not resize shared memory segment "/PostgreSQL.2088012784" to 50438144 bytes: No space left on device

I couldn't really find how to calculate the required size of /dev/shm looking at the documentation. Which Postgres configuration options affect the required size and would it be feasable to tune shm_size accordingly?

Maybe it would be worth to extend the image documentation.

@otbutz
Copy link
Author

otbutz commented Feb 21, 2018

According to @macdice the issue seems to be triggered by complex queries and an increased number of max_parallel_workers_per_gather (tested with 4; the default is 2).

@tianon
Copy link
Member

tianon commented Feb 23, 2018

Indeed, the default in Docker for /dev/shm size is 64MB:

$ docker run -it --rm alpine:3.7 df -hT /dev/shm
Filesystem           Type            Size      Used Available Use% Mounted on
shm                  tmpfs          64.0M         0     64.0M   0% /dev/shm

There is also a --shm-size argument to docker run which can be used to adjust this:

$ docker run -it --rm --shm-size 128m alpine:3.7 df -hT /dev/shm
Filesystem           Type            Size      Used Available Use% Mounted on
shm                  tmpfs         128.0M         0    128.0M   0% /dev/shm

This is not something the image can set automatically, and as you alluded to, I think the "recommended value" is going to vary from deployment to deployment (based on both user requirements and supplied configuration).

@otbutz
Copy link
Author

otbutz commented Feb 26, 2018

I think it would be a good idea to add it to the image documentation. The limited /dev/shm size is a potential pitfal as the error in the Postgres log isn't really straightforward and will only affect containerized Postgres installations.

@wglambert wglambert added question Usability question, not directly related to an error with the image Request Request for image modification or feature labels Apr 25, 2018
@turicas
Copy link

turicas commented Aug 8, 2018

I think at least the information about changing the default SHM size should be added to the documentation (like a tip: "You may want to change the default shared memory by passing --shm-size=256M to docker run"). I did not found the file which maps to the "Full Description" section on postgres page on docker hub - where I can find it so I can submit a PR?

Related issue (change SHM size of a running container): docker/cli#1278

@yosifkit
Copy link
Member

@turicas 😉

@tianon tianon closed this as completed Sep 28, 2018
erthalion added a commit to zalando/postgres-operator that referenced this issue Dec 21, 2018
Add possibility to mount a tmpfs volume to /dev/shm to avoid issues like
[this](docker-library/postgres#416). To achieve that
two new options were introduced:

* `enableShmVolume` to PostgreSQL manifest, to specify whether or not mount
this volume per database cluster

* `enable_shm_volume` to operator configuration, to specify whether or not mount
per operator.

The first one, `enableShmVolume` takes precedence to allow us to be more flexible.
k8s-ci-robot pushed a commit to helm/charts that referenced this issue Nov 21, 2019
* [stable/postgresql] Add dedicated tmpsfs for /dev/shm.

Start a database pod without limitations on shm memory. By default docker
limit  to  (see e.g. the [docker
issue](docker-library/postgres#416), which could be
not enough if PostgreSQL uses parallel workers heavily. If this option is
present and value is , to the target database pod will be mounted a new
tmpfs volume to remove this limitation.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>

* [stable/postgresql] SHM: Second version after review + improvements.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>
JoseAlban pushed a commit to JoseAlban/charts that referenced this issue Nov 22, 2019
* [stable/postgresql] Add dedicated tmpsfs for /dev/shm.

Start a database pod without limitations on shm memory. By default docker
limit  to  (see e.g. the [docker
issue](docker-library/postgres#416), which could be
not enough if PostgreSQL uses parallel workers heavily. If this option is
present and value is , to the target database pod will be mounted a new
tmpfs volume to remove this limitation.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>

* [stable/postgresql] SHM: Second version after review + improvements.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>
crmarques pushed a commit to crmarques/charts that referenced this issue Nov 29, 2019
* [stable/postgresql] Add dedicated tmpsfs for /dev/shm.

Start a database pod without limitations on shm memory. By default docker
limit  to  (see e.g. the [docker
issue](docker-library/postgres#416), which could be
not enough if PostgreSQL uses parallel workers heavily. If this option is
present and value is , to the target database pod will be mounted a new
tmpfs volume to remove this limitation.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>

* [stable/postgresql] SHM: Second version after review + improvements.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>
Signed-off-by: Carlos Roberto Marques Junior <carlos.marques@bndes.gov.br>
hakman pushed a commit to hakman/charts that referenced this issue Dec 5, 2019
* [stable/postgresql] Add dedicated tmpsfs for /dev/shm.

Start a database pod without limitations on shm memory. By default docker
limit  to  (see e.g. the [docker
issue](docker-library/postgres#416), which could be
not enough if PostgreSQL uses parallel workers heavily. If this option is
present and value is , to the target database pod will be mounted a new
tmpfs volume to remove this limitation.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>

* [stable/postgresql] SHM: Second version after review + improvements.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>
dargolith pushed a commit to dargolith/charts that referenced this issue Jan 10, 2020
* [stable/postgresql] Add dedicated tmpsfs for /dev/shm.

Start a database pod without limitations on shm memory. By default docker
limit  to  (see e.g. the [docker
issue](docker-library/postgres#416), which could be
not enough if PostgreSQL uses parallel workers heavily. If this option is
present and value is , to the target database pod will be mounted a new
tmpfs volume to remove this limitation.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>

* [stable/postgresql] SHM: Second version after review + improvements.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>
teor2345 added a commit to teor2345/zebra that referenced this issue Nov 20, 2020
Some systems have a very small /dev/shm, for example, see:
docker-library/postgres#416

So we should just use the temporary directory on all operating systems.

Also:
* use TempDir to generate the temporary path
* delete the code that we copied from sled
* prefix the temporary path with the state version and network
teor2345 added a commit to ZcashFoundation/zebra that referenced this issue Nov 20, 2020
Some systems have a very small /dev/shm, for example, see:
docker-library/postgres#416

So we should just use the temporary directory on all operating systems.

Also:
* use TempDir to generate the temporary path
* delete the code that we copied from sled
* prefix the temporary path with the state version and network
YuriSalesquw pushed a commit to YuriSalesquw/postgres-operator that referenced this issue Dec 26, 2022
Add possibility to mount a tmpfs volume to /dev/shm to avoid issues like
[this](docker-library/postgres#416). To achieve that
two new options were introduced:

* `enableShmVolume` to PostgreSQL manifest, to specify whether or not mount
this volume per database cluster

* `enable_shm_volume` to operator configuration, to specify whether or not mount
per operator.

The first one, `enableShmVolume` takes precedence to allow us to be more flexible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image Request Request for image modification or feature
Projects
None yet
Development

No branches or pull requests

5 participants