You might need to increase max_locks_per_transaction

Traceback (most recent call last):
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.OutOfMemory: out of shared memory
HINT:  You might need to increase max_locks_per_transaction.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/django/core/management/commands/flush.py", line 63, in handle
    connection.ops.execute_sql_flush(sql_list)
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/django/db/backends/base/operations.py", line 408, in execute_sql_flush
    cursor.execute(sql)
  File "/home/circleci/project/venv_3_9_10/src/graphene-django/graphene_django/debug/sql/tracking.py", line 155, in execute
    return self._record(self.cursor.execute, sql, params)
  File "/home/circleci/project/venv_3_9_10/src/graphene-django/graphene_django/debug/sql/tracking.py", line 101, in _record
    return method(sql, params)
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/raven/contrib/django/client.py", line 127, in execute
    return real_execute(self, sql, params)
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/circleci/project/venv_3_9_10/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.OperationalError: out of shared memory
HINT:  You might need to increase max_locks_per_transaction.

Recently got this error while trying to upgrade postgres.

I’ve tried bumping up the number of max locks via a custom postgres image, something like:

# Circle CIs base image
FROM cimg/postgres:14.2
RUN if [ -e /usr/local/share/postgresql/postgresql.conf.sample ]; then \
        postgresfile=/usr/local/share/postgresql/postgresql.conf.sample; \
    else \
        postgresfile=/usr/share/postgresql/postgresql.conf.sample; \
    fi && \
    echo max_connections=200 >> $postgresfile &&\
    echo max_locks_per_transaction=10000 >> $postgresfile

However, maybe the docker /dev/shm of 64MB might be coming into play?

Within the circleci instance:

circleci@f2057a1c361c:~$ sysctl -a | grep shm

kernel.shm_rmid_forced = 0
kernel.shmall = 18446744073692774399
kernel.shmmax = 18446744073692774399
kernel.shmmni = 4096
vm.hugetlb_shm_group = 0

I was told recently in a support ticket about /mnt/ramdisk which is similar to /dev/shm in that it is a mounted ram disk with execute allowed.

Anyone have any ideas on this?