Google Cloud SQL PG11 : could not resize shared memory segment

荒凉一梦 提交于 2019-12-05 09:12:24

This worked for me, I think google needs to change a flag on how they're starting the postgres container on their end that we can't influence inside postgres.

https://www.postgresql.org/message-id/CAEepm%3D2wXSfmS601nUVCftJKRPF%3DPRX%2BDYZxMeT8M2WwLSanVQ%40mail.gmail.com

Bingo. Somehow your container tech is limiting shared memory. That error is working as designed. You could figure out how to fix the mount options, or you could disable parallelism with max_parallel_workers_per_gather = 0.

show max_parallel_workers_per_gather;
-- 2
-- Run your query
-- Query fails
alter user ${MY_PROD_USER} set max_parallel_workers_per_gather=0;
-- Run query again -- query should work
alter user ${MY_PROD_USER} set max_parallel_workers_per_gather=2;
-- -- Run query again -- fails

You may consider increasing Tier of the instance, that will have influence on machine memory, vCPU cores, and resources available to your Cloud SQL instance. Check available machine types

In Google Cloud SQL PostgreSQL is also possible to change database flags, that have influence on memory consumption:

  • max_connections: some memory resources can be allocated per-client, so the maximum number of clients suggests the maximum possible memory use
  • shared_buffers: determines how much memory is dedicated to PostgreSQL to use for caching data
  • autovacuum - should be on.

I recommend lowering the limits, to lower memory consumption.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!