My Mayan instance only serves requests for a very short time before the web server shuts down with the following message:
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2024-01-09 10:40:09,519 WARN exited: mayan-edms-gunicorn (exit status 1; not expected)
This seems to be caused by the workers not being able to initialize the locking backend.
When I configure the application to use the FileLock
ing backend, this is the error message I’m getting from each of the workers:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/lock_manager/backends/file_lock.py", line 87, in _init
raise LockError
mayan.apps.lock_manager.exceptions.LockError
The following is the relevant part of file_lock.py, around line 87:
# Someone already got this lock, check to see if it is expired.
if file_locks[name]['expiration'] and time.time() > file_locks[name]['expiration']:
# It expires and has expired, we re-acquired it.
file_locks[name] = self._get_lock_dictionary()
else:
lock.release()
raise LockError
So there is a lock with the given name and either it doesn’t have an expiration date or the expiration date is None
or some time in the future.
Since this happens in all the worker processes, I’m assuming that this is either something in the file system or a race condition, but that’s really hard to debug without knowing the code base very well.
If I activate the redis locking backend, this is what I get instead of the above error:
File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/lock_manager/backends/redis_lock.py", line 73, in _init
raise LockError
The relevant part of redis_lock.py
reads:
if _redis_lock_instance.acquire(blocking=False):
self._redis_lock_instance = _redis_lock_instance
else:
raise LockError
So, again, a lock cannot be acquired.
Since this is logically the same for both backends, with completely different locking mechanisms, I’m assuming the root cause is indeed a race condition.
I’m starting Mayan using docker-compose (docker compose up -d
) with the following .env file:
COMPOSE_PROJECT_NAME=mayan
COMPOSE_PROFILES=all_in_one,postgresql,rabbitmq,redis,elasticsearch
MAYAN_DOCKER_IMAGE_NAME=mayanedms
MAYAN_DOCKER_IMAGE_TAG=v4.5.5
MAYAN_FRONTEND_HTTP_PORT=8002
MAYAN_WORKER_CUSTOM_QUEUE_LIST=
MAYAN_DOCKER_WAIT="postgresql:5432 rabbitmq:5672 redis:6379"
MAYAN_TRAEFIK_LETS_ENCRYPT_EMAIL=
MAYAN_TRAEFIK_EXTERNAL_DOMAIN=
MAYAN_TRAEFIK_DASHBOARD_ENABLE=false
MAYAN_TRAEFIK_DASHBOARD_AUTHENTICATION=''
MAYAN_TRAEFIK_FRONTEND_ENABLE=false
MAYAN_TRAEFIK_RABBITMQ_ENABLE=false
MAYAN_TRAEFIK_LETS_ENCRYPT_DNS_CHALLENGE_PROVIDER=
MAYAN_LOCK_MANAGER_BACKEND=mayan.apps.lock_manager.backends.file_lock.FileLock