Re: LMDB reader leak with Cyrus IMAP + SASL

Howard Chu <[email protected]> Sat, 6 Jun 2026 14:18:45 +0100
Newsgroups gmane.mail.imap.cyrus
Message-ID <[email protected]>
Dag-Erling Sm=C3=B8rgrav wrote:
> Cyrus IMAP 3.8.6, Cyrus SASL 2.1.28, LMDB 0.9.35 on FreeBSD 14.4.
>=20
> I'm using auxprop, not saslauthd.  I recently switched my sasldb from
> BDB to LMDB.  Since then, every couple of days the IMAP server stops
> authenticating clients until I restart it.  Each attempt to connect
> results in the following log messages on the server:
>=20
>     imaps[85496]: SASL unable to open MDB transaction: MDB_READERS_FULL: =
Environment maxreaders limit reached
>     imaps[85496]: badlogin: redacted [redacted] plaintext (des) [SASL(-1)=
: generic failure: checkpass failed]
>=20
> The database has 128 registered readers, which I assume is the limit:

That implies that LMDB isn't being closed properly, which is done by sasldb=
_auxprop_free().

>     # mdb_stat -rn /usr/local/etc/sasldb2 | wc -l
>          128
>=20
> However, there are only three active imaps processes:
>=20
>     # fstat /usr/local/etc/sasldb2*
>     USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W=
 NAME
>     cyrus    imapd      79119   10 /        132265 -rw-r-----   32768  r =
 /usr/local/etc/sasldb2
>     cyrus    imapd      79119   11 /        131427 -rw-r-----    8192 rw =
 /usr/local/etc/sasldb2-lock
>     cyrus    imapd      79186   10 /        132265 -rw-r-----   32768  r =
 /usr/local/etc/sasldb2
>     cyrus    imapd      79186   11 /        131427 -rw-r-----    8192 rw =
 /usr/local/etc/sasldb2-lock
>     cyrus    imapd      79200   10 /        132265 -rw-r-----   32768  r =
 /usr/local/etc/sasldb2
>     cyrus    imapd      79200   11 /        131427 -rw-r-----    8192 rw =
 /usr/local/etc/sasldb2-lock
>     # ps -xU cyrus
>       PID TT  STAT    TIME COMMAND
>     56124  -  SsJ  0:01.48 /usr/local/cyrus/libexec/master -d
>     56127  -  SJ   0:02.07 idled
>     56129  -  IJ   0:00.01 notifyd
>     79119  -  IJ   0:00.43 imapd: imaps: [redacted] des re.dac.ted Idle (=
imapd)
>     79186  -  IJ   0:24.63 imapd: imaps: redacted [redacted] des re.dac.t=
ed  (imapd)
>     79200  -  IJ   0:00.37 imapd: imaps: redacted [redacted] des re.dac.t=
ed Idle (imapd)
>     85835  -  SJ   0:00.02 lmtpd
>=20
> All the readers match past or present imaps processes.  There is no sign
> in the logs to suggest that any of them met an abnormal fate.
>=20
> Restarting imapd immediately clears up the issue:
>=20
>     # service imapd restart
>     Stopping cyrus_imapd.
>     Waiting for PIDS: 56124.
>     Starting cyrus_imapd.
>     # mdb_stat -rn /usr/local/etc/sasldb2 | wc -l
>            2
>=20
> DES
>=20


--=20
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/

------------------------------------------
Cyrus: Info
Permalink: https://cyrus.topicbox.com/groups/info/Ta8a8ec710afb50b8-Ma90be3=
c2e00ac7a35bedbbe6
Delivery options: https://cyrus.topicbox.com/groups/info/subscription