RHDS - What is the value range for database locks (nsslapd-db-locks)?

Solution Verified - Updated -

Environment

Red Hat Directory Server 11
Red Hat Directory Server 10
Red Hat Enterprise Linux 8
Red Hat Enterprise Linux 7

Issue

RHDS is logging error messages stating that there are no available locks:

libdb: BDB2055 Lock table is out of available lock entries 

The documentation about Tuning the Number of Locks recommends to increase the number of locks when this happens.

But there is no mention about the value range for the nsslapd-db-locks attribute.

Resolution

Since 389-ds 1.3.5, there is a check to make sure that the number of locks is higher or equal to 10000.
So the minimum value for nsslapd-db-locks is 10000.

What about the maximum value?
From the Berkeley DB documentation the variable is an u_int32_t

Therefore a theoretical maximum value would be 4294967295.
Obviously this is way too high.

Berkeley DB Reference Guide gives a rough estimation:

The maximum number of locks required by an application cannot be easily estimated. It is possible to calculate a maximum number of locks by multiplying the maximum number of lockers, times the maximum number of lock objects, times two (two for the two possible lock modes for each object, read and write). However, this is a pessimal value, and real applications are unlikely to actually need that many locks. Reviewing the Lock subsystem statistics is the best way to determine this value.

Example:

nsslapd-db-lockers: 840
...
nsslapd-db-max-lock-objects: 49574

That gives 840 * 49574 * 2 = 83284320

We usually recommend to set the nsslapd-db-locks from the default value of 10000 to 50000.
In case the logging of the message Lock table is out of available lock entries continues,
setting it to 100000 usually fixes the issue.

Root Cause

RHDS lock table is out of available locks.
How can I estimate the needed number of locks?

Diagnostic Steps

The message Lock table is out of available lock entries will be written in the errors log.
Example:

21/Apr/2017:12:11:53.184281028 +0000] libdb: BDB2055 Lock table is out of available lock entries
[21/Apr/2017:12:11:53.184935556 +0000] NSMMReplicationPlugin - changelog program - _cl5CompactDBs: failed to compact f85eed3d-0ef011e7-a15b8665-e18a8581; db error - 12 Cannot allocate memory
[21/Apr/2017:12:12:47.408414516 +0000] libdb: BDB2055 Lock table is out of available lock entries
[21/Apr/2017:12:12:47.409223182 +0000] agmt="cn=<AGREEMENT_NAME>" (<HOST>:<PORT>) - Can't locate CSN 58e487fc001700110000 in the changelog (DB rc=12). If replication stops, the consumer may need to be reinitialized.
[21/Apr/2017:12:12:47.409924951 +0000] libdb: BDB2055 Lock table is out of available lock entries
[21/Apr/2017:12:12:47.410745979 +0000] libdb: BDB2055 Lock table is out of available lock entries
[21/Apr/2017:12:12:47.411535850 +0000] agmt="cn=<AGREEMENT_NAME>" (<HOST>:<PORT>) - Can't locate CSN 58e487fc00bf00110000 in the changelog (DB rc=12). If replication stops, the consumer may need to be reinitialized. 

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.