Bug 58443 - check number of indices in ldap_setup_index
Summary: check number of indices in ldap_setup_index
Status: CLOSED FIXED
Alias: None
Product: UCS
Classification: Unclassified
Component: LDAP
Version: UCS 5.2
Hardware: Other Linux
: P5 normal
Target Milestone: UCS 5.2-2-errata
Assignee: Arvid Requate
QA Contact: Christian Castens
URL: https://bugs.openldap.org/show_bug.cg...
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-02 10:30 CEST by Jürn Brodersen
Modified: 2025-08-13 16:50 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Customer ID:
Max CVSS v3 score:


Attachments
0001-ITS-9895-slapd-mdb-raise-MDB_INDICES-from-128-to-256.patch (717 bytes, patch)
2025-07-04 17:08 CEST, Arvid Requate
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jürn Brodersen univentionstaff 2025-07-02 10:30:57 CEST
check number of indices in ldap_setup_index

Our school ID Broker env broke because we ran out of indices (max 128 in 5.2, though it was increased to 256 in new openldap versions)

If I understand this correctly, we currently have 29 indices free to use in a 5.2 school environment. If we configure to many, the ldap server refuses to start with the following error message:

MDB_DBS_FULL: Environment maxdbs limit reached

It would be helpful if our "ldap_setup_index" tool could check we number of used ldap indices and throw an error if we already have set up too many indices.

I think an error in ldap_setup_index would be preferred over a stopped ldap server.


Context:
We want to add a new index in UCS@school, but we are not sure how many indices are already in use in customer environments and don't want to break them.

ldap_setup_index:
https://git.knut.univention.de/univention/dev/ucs/-/blob/5.2-2/management/univention-ldap/scripts/ldap_setup_index
Comment 1 Arvid Requate univentionstaff 2025-07-04 17:08:42 CEST
Created attachment 11324 [details]
0001-ITS-9895-slapd-mdb-raise-MDB_INDICES-from-128-to-256.patch

Ok, additionally we could pick up the OpenLDAP patch from
https://bugs.openldap.org/show_bug.cgi?id=9895

I did a short check by compiling the UCS 5.2 openldap source package with the additional patch and there where no issues. It just changes the the input to 
mdb_env_set_maxdbs and
http://www.lmdb.tech/doc/group__mdb.html#gaa2fc2f1f37cb1115e733b62cab2fcdbc
says "a moderate number of slots are cheap but a huge number gets expensive".
Since Howard Chu, the author of LMDB and maintainer of OpenLDAP chose to raise
the value to 256 for the upstream maintained OpenLDAP versions, I think this is
considered still a "moderate number".

Unfortunately mdb_stat doesn't tell this value, but OTOH that also support the impression that it's a run-time parameter specified during mdb_db_open and not "tattooed" into the database itself (but obviously the number of actual sub-dbs used for indices are stored in the database). So, no database dump+restore or re-index should/will be necessary.
Comment 2 Arvid Requate univentionstaff 2025-08-08 11:55:08 CEST
ucs-patches:
7de2f5306 | main | feat: Allow loading multiple instances of memberof overlay
23564f661 | main | ITS#9895 slapd-mdb: raise MDB_INDICES from 128 to 256
1fe876f9f | main | Revert "feat: Allow loading multiple instances of memberof overlay"

Package: openldap
Version: 2.5.13+dfsg-5A~5.2.0.202508061256
Release: 5.2-0
Scope: errata5.2-2

ucs:
f50ddd60ee0 | 5.2-2 | feat(ldap): ldap_setup_index now checks if number of indexed attributes would exceed maximum number of lmdb sub-databases
1003e14ff57 | 5.2-2 | chore: Advisory for OpenLDAP

Package: univention-ldap
Version: 18.2.6
Release: 5.2-0
Scope: errata5.2-2
Comment 3 Christian Castens univentionstaff 2025-08-08 12:02:37 CEST
QA:
  OK: code review
  OK: advisories
  OK: manual test - script exits with error if it tries to add another index but the index limit is already reached