[Solved] RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

When things don't work as they should.
amphetamine
Posts: 47
Joined: Sat Jul 04, 2020 8:43 am

[Solved] RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by amphetamine »

https://docs.mayan-edms.com/releases/4.1.html
follow the Direct deployment instruction on STEP 10, and get the error message, how can I do next?
Now SERVER ALSO "Server communication error"

/$ sudo -u mayan MAYANMEDIAROOT=/opt/mayan-edms/media/ \

> /opt/mayan-edms/bin/mayan-edms.py platformtemplate supervisord | sudo sh -c "cat > /etc/supervisor/conf.d/mayan-edms.conf"

Traceback (most recent call last):

File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/apps.py", line 29, in ready

lock = lock*instance.acquire*lock(


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/base.py", line 32, in acquirelock

return cls.*acquire*lock(name=name, timeout=timeout)


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/redislock.py", line 20, in acquirelock

return RedisLock(name=name, timeout=timeout)


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/backends/base.py", line 48, in init

return self._init(*args,* \*kwargs)


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/redislock.py", line 70, in _init

if *redis*lock_instance.acquire(blocking=False):


File "/opt/mayan-edms/lib/python3.8/site-packages/redis/lock.py", line 182, in acquire

if self.do_acquire(token):


File "/opt/mayan-edms/lib/python3.8/site-packages/redis/lock.py", line 197, in do_acquire

if self.redis.set(self.name, token, nx=True, px=timeout):


File "/opt/mayan-edms/lib/python3.8/site-packages/redis/client.py", line 1766, in set

return self.execute_command('SET', \*pieces)


File "/opt/mayan-edms/lib/python3.8/site-packages/redis/client.py", line 875, in execute_command

conn = self.connection or pool.get*connection(command*name, \*\*options)


File "/opt/mayan-edms/lib/python3.8/site-packages/redis/connection.py", line 1185, in get_connection

connection.connect()


File "/opt/mayan-edms/lib/python3.8/site-packages/redis/connection.py", line 561, in connect

self.on_connect()


File "/opt/mayan-edms/lib/python3.8/site-packages/redis/connection.py", line 658, in on_connect

if nativestr(self.read_response()) != 'OK':


File "/opt/mayan-edms/lib/python3.8/site-packages/redis/connection.py", line 752, in read_response

raise response


redis.exceptions.ResponseError: DB index is out of range

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

Traceback (most recent call last):

File "/opt/mayan-edms/bin/mayan-edms.py", line 10, in <module>

execute*from*command_line(sys.argv)


File "/opt/mayan-edms/lib/python3.8/site-packages/django/core/management/init.py", line 381, in executefromcommand_line

utility.execute()


File "/opt/mayan-edms/lib/python3.8/site-packages/django/core/management/init.py", line 357, in execute

django.setup()


File "/opt/mayan-edms/lib/python3.8/site-packages/django/init.py", line 24, in setup

apps.populate(settings.INSTALLED_APPS)


File "/opt/mayan-edms/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate

app_config.ready()


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/apps.py", line 34, in ready

raise RuntimeError(


RuntimeError: Error initializing the locking backend: mayan.apps.lockmanager.backends.redislock.RedisLock; DB index is out of range
Last edited by amphetamine on Mon Oct 25, 2021 4:10 am, edited 1 time in total.
User avatar
rosarior
Developer
Developer
Posts: 688
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by rosarior »

Restart Redis for the configuration change that increases the number of databases to 3 to take effect.

Code: Select all

sudo service redis-server restart
Seems that step is missing from the documentation. We'll make the update.

Thanks for the report.
amphetamine
Posts: 47
Joined: Sat Jul 04, 2020 8:43 am

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by amphetamine »

sudo service redis-server restart
then,

Code: Select all

/$ sudo -u mayan MAYANMEDIAROOT=/opt/mayan-edms/media/ \

> /opt/mayan-edms/bin/mayan-edms.py platformtemplate supervisord | sudo sh -c "cat > /etc/supervisor/conf.d/mayan-edms.conf"
and got the same error :?

How to fix?
User avatar
rosarior
Developer
Developer
Posts: 688
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by rosarior »

According to Redis documentation, https://redis.io/commands/select:

Code: Select all

DB index is out of range
Means that the database number you are attempting to use is out of the range of the number of databases you have told Redis to provision.

Double check that Mayan's

Code: Select all

LOCK_MANAGER_BACKEND_ARGUMENTS
(which in the instructions is 2)

Code: Select all

LOCK_MANAGER_BACKEND_ARGUMENTS: {'redis_url':'redis://:mayanredispassword@<IP address of Redis server>:6379/2'}
does not use a database number higher than what Redis has been told to allocate:

Code: Select all

databases 3
Most likely there is a syntax error in the LOCK_MANAGER_BACKEND_ARGUMENTS setting.
amphetamine
Posts: 47
Joined: Sat Jul 04, 2020 8:43 am

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by amphetamine »

Still got the same error, :shock:

my setting

Code: Select all

LOCKMANAGERBACKEND: mayan.apps.lockmanager.backends.redislock.RedisLock

LOCKMANAGERBACKENDARGUMENTS: {'redisurl':'redis://:mayanredispassword@127.0.0.1:6379/2'}
Databases 16 to 3

Code: Select all

databases 3
amphetamine
Posts: 47
Joined: Sat Jul 04, 2020 8:43 am

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by amphetamine »

upgrade the SUPERVISORD to 4.2.2 and follow the upgrade instructions.

and found the file (mayan-edms.conf and mayan-edms.conf.bak) size are 0 k (blank content), are they related the issue?
/etc/supervisor/conf.d/mayan-edms.conf
/etc/supervisor/conf.d/mayan-edms.conf.bak
amphetamine
Posts: 47
Joined: Sat Jul 04, 2020 8:43 am

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by amphetamine »

TRY Again, moved the Folders

Code: Select all

mv document_cache document_file_page_image_cache
mv document_storage document_file_storage
and changed the configuration:

Code: Select all

DOCUMENTS_CACHE_STORAGE_BACKEND           -> DOCUMENTS_FILE_PAGE_IMAGE_CACHE_STORAGE_BACKEND
DOCUMENTS_CACHE_STORAGE_BACKEND_ARGUMENTS -> DOCUMENTS_FILE_PAGE_IMAGE_CACHE_STORAGE_BACKEND_ARGUMENTS
DOCUMENTS_STORAGE_BACKEND                 -> DOCUMENTS_FILE_STORAGE_BACKEND
DOCUMENTS_STORAGE_BACKEND_ARGUMENTS       -> DOCUMENTS_FILE_STORAGE_BACKEND_ARGUMENTS
got

Code: Select all

sudo -u mayan MAYANMEDIAROOT=/opt/mayan-edms/media/ /opt/mayan-edms/bin/mayan-edms.py platformtemplate supervisord | sudo sh -c "cat > /etc/supervisor/conf.d/mayan-edms.conf"

Traceback (most recent call last):

  File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/apps.py", line 29, in ready

    lock = lockinstance.acquirelock(

  File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/base.py", line 32, in acquirelock

    return cls.acquirelock(name=name, timeout=timeout)

  File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/redislock.py", line 20, in acquirelock

    return RedisLock(name=name, timeout=timeout)

  File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/backends/base.py", line 48, in init

    return self._init(args, *kwargs)

  File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/redislock.py", line 70, in _init

    if redislock_instance.acquire(blocking=False):

  File "/opt/mayan-edms/lib/python3.8/site-packages/redis/lock.py", line 182, in acquire

    if self.do_acquire(token):

  File "/opt/mayan-edms/lib/python3.8/site-packages/redis/lock.py", line 197, in do_acquire

    if self.redis.set(self.name, token, nx=True, px=timeout):

  File "/opt/mayan-edms/lib/python3.8/site-packages/redis/client.py", line 1766, in set

    return self.execute_command('SET', *pieces)

  File "/opt/mayan-edms/lib/python3.8/site-packages/redis/client.py", line 875, in execute_command

    conn = self.connection or pool.getconnection(commandname, **options)

  File "/opt/mayan-edms/lib/python3.8/site-packages/redis/connection.py", line 1185, in get_connection

    connection.connect()

  File "/opt/mayan-edms/lib/python3.8/site-packages/redis/connection.py", line 561, in connect

    self.on_connect()

  File "/opt/mayan-edms/lib/python3.8/site-packages/redis/connection.py", line 658, in on_connect

    if nativestr(self.read_response()) != 'OK':

  File "/opt/mayan-edms/lib/python3.8/site-packages/redis/connection.py", line 752, in read_response

    raise response

redis.exceptions.ResponseError: DB index is out of range

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

Traceback (most recent call last):

  File "/opt/mayan-edms/bin/mayan-edms.py", line 10, in <module>

    executefromcommand_line(sys.argv)

  File "/opt/mayan-edms/lib/python3.8/site-packages/django/core/management/init.py", line 381, in executefromcommand_line

    utility.execute()

  File "/opt/mayan-edms/lib/python3.8/site-packages/django/core/management/init.py", line 357, in execute

    django.setup()

  File "/opt/mayan-edms/lib/python3.8/site-packages/django/init.py", line 24, in setup

    apps.populate(settings.INSTALLED_APPS)

  File "/opt/mayan-edms/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate

    app_config.ready()

  File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/apps.py", line 34, in ready

    raise RuntimeError(

RuntimeError: Error initializing the locking backend: mayan.apps.lockmanager.backends.redislock.RedisLock; DB index is out of range
Any idea to fix that?
User avatar
michael
Developer
Developer
Posts: 277
Joined: Sun Apr 19, 2020 6:21 am

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by michael »

Execute this:

Code: Select all

sudo -u mayan MAYANMEDIAROOT=/opt/mayan-edms/media/ /opt/mayan-edms/bin/mayan-edms.py showsettings LOCK_MANAGER
And paste here the value of LOCK_MANAGER_BACKEND, LOCK_MANAGER_BACKEND_ARGUMENTS and LOCK_MANAGER_DEFAULT_LOCK_TIMEOUT

Remove any password in the value of the setting.

Paste also the content of the entire Redis config file, removing any password.
amphetamine
Posts: 47
Joined: Sat Jul 04, 2020 8:43 am

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by amphetamine »

Code: Select all

sudo -u mayan MAYANMEDIAROOT=/opt/mayan-edms/media/ /opt/mayan-edms/bin/mayan-edms.py showsettings LOCK_MANAGER

Code: Select all

/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/common/apps.py:137: DatabaseWarning: Your database backend is set to use SQLite. SQLite should only be used for development and testing, not for production.

warnings.warn(

Traceback (most recent call last):

File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/apps.py", line 29, in ready

lock = lock*instance.acquire*lock(


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/base.py", line 32, in acquirelock

return cls.*acquire*lock(name=name, timeout=timeout)


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/filelock.py", line 26, in acquirelock

instance = FileLock(name=name, timeout=timeout)


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/backends/base.py", line 45, in init

self.**class**._initialize()


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lockmanager/backends/filelock.py", line 36, in _initialize

open(file=cls.lock_file, mode='a').close()


PermissionError: [Errno 13] Permission denied: '/tmp/65daa52b1e20b0c3ff31fe741bcad63a4d236eb461e5508555c3a6ad7b928b37'

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

Traceback (most recent call last):

File "/opt/mayan-edms/bin/mayan-edms.py", line 10, in <module>

execute*from*command_line(sys.argv)


File "/opt/mayan-edms/lib/python3.8/site-packages/django/core/management/init.py", line 381, in executefromcommand_line

utility.execute()


File "/opt/mayan-edms/lib/python3.8/site-packages/django/core/management/init.py", line 357, in execute

django.setup()


File "/opt/mayan-edms/lib/python3.8/site-packages/django/init.py", line 24, in setup

apps.populate(settings.INSTALLED_APPS)


File "/opt/mayan-edms/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate

app_config.ready()


File "/opt/mayan-edms/lib/python3.8/site-packages/mayan/apps/lock_manager/apps.py", line 34, in ready

raise RuntimeError(


RuntimeError: Error initializing the locking backend: mayan.apps.lockmanager.backends.filelock.FileLock; [Errno 13] Permission denied: '/tmp/65daa52b1e20b0c3ff31fe741bcad63a4d236eb461e5508555c3a6ad7b928b37'

Code: Select all

LOCK_MANAGER_BACKEND: mayan.apps.lock_manager.backends.redis_lock.RedisLock
LOCK_MANAGER_BACKEND_ARGUMENTS: {'redis_url':'redis://:******@127.0.0.1:6379/2'}
LOCK_MANAGER_DEFAULT_LOCK_TIMEOUT: 30
Redis.conf.txt.zip
(20.43 KiB) Downloaded 64 times
User avatar
michael
Developer
Developer
Posts: 277
Joined: Sun Apr 19, 2020 6:21 am

Re: RuntimeError: Error initializing the locking backend 3.5.10 > 4.1

Post by michael »

The Redis config file sets the databases to 3 at the beginning but then sets it back to 2 at the end. Remove the duplicated databases setting and just one instance of it setting the value to 3. Restart Redis and retry the upgrade steps.

There are also multiple requirepass settings. Remove the duplicates and keep just one with the correct password.

Hope this helps.
Post Reply