[pfx] Postfix is incompatible with LMDB 1.0
Christian Pfeiffer via Postfix-users <[email protected]> Thu, 02 Jul 2026 17:37:57 +0200
| Newsgroups | gmane.mail.postfix.user |
|---|---|
| Message-ID | <[email protected]> |
--===============8941839574997696508== Content-Type: multipart/alternative; boundary="----=_=-_OpenGroupware_org_NGMime-4283-1783006677.054223-3------" ------=_=-_OpenGroupware_org_NGMime-4283-1783006677.054223-3------ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Length: 2488 Hi, I'm writing this in the context of ArchLinux pushing LMDB 1.0 into test= ing. It turns out that aside from a need to convert the LMDB databases by us= ing mdb=5Fdump before the upgrade and mdb=5Fload to recreate them after= wards (or running newaliases and postmap -F again for Postfix specifica= lly), there are some compatibility problems. The first issue is that with LMDB 1.0, running either postmap or newali= ases now causes the following message postmap: fatal: error updating lmdb:./aliases: MDB=5FBAD=5FTXN: Transac= tion must abort, has a child, or is invalid I looked at it with GDB, the cause for this is a change in LMDB 1.0, na= mely this commit: ITS#8174 LMDB: fixes for mdb=5Fdrop(MAIN=5FDBI) =C2=B7 LMDB/lmdb@d0fcfd= 3 Dropping the MAIN=5FDBI now causes the transaction to be marked MDB=5FT= XN=5FDIRTY and MDB=5FTXN=5FDROPPED, which means any further usage of th= e transaction that was used to drop MAIN=5FDBI will cause MDB=5FBAD=5FT= XN. For Postfix, all databases are dropped by slmdb=5Fprepare with this sta= tement: postfix/postfix/src/util/slmdb.c at v3.11.4 =C2=B7 vdukhovni/po= stfix This causes lmdb/libraries/liblmdb/mdb.c at mdb.master3 =C2=B7 LMDB/lmd= b to mark the transaction as dirty & dropped, and then when slmdb=5Fput= is called, it will call mdb=5Fput with the same transaction handle her= e postfix/postfix/src/util/slmdb.c at master =C2=B7 vdukhovni/postfix c= ausing MDB=5FBAD=5FTXN to be returned from here lmdb/libraries/liblmdb/= mdb.c at mdb.master3 =C2=B7 LMDB/lmdb . Now, I've made a temporary fix for Arch: Postfix LMDB 1.0 fix .=C2=A0 I'm not sure this is the right approach, and it doesn't seem to fix all= problems yet, as calling newaliases again on an already existing LMDB = now causes duplicate key warnings, so I don't think this is right or co= mplete just yet. My approach was to make slmdb=5Fprepare to drop the da= tabase, then abort the transaction as is required, being a new one, and= then reopen the database with mdb=5Fdbi=5Fopen. For reference, this is the downstream discussion at Arch: version 1.0.0= in testing breaks postfix (#5) =C2=B7 Issue =C2=B7 archlinux/packaging= /packages/lmdb It covers LMDB 1.0 in general (other apps like bogofilte= r also have issues not yet identified), but the discussion regarding Po= stfix is in there, too. But obviously, I would want to get this fixed upstream rather than doin= g any downstream patching experiments. Regards, Christian Pfeiffer ------=_=-_OpenGroupware_org_NGMime-4283-1783006677.054223-3------ Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Length: 3567 <html><p>Hi,</p><p>I'm writing this in the context of ArchLinux pushing= LMDB 1.0 into testing.</p><p>It turns out that aside from a need to co= nvert the LMDB databases by using <code>mdb=5Fdump</code> before the up= grade and <code>mdb=5Fload</code> to recreate them afterwards (or runni= ng <code>newaliases</code> and <code>postmap -F</code> again for Postfi= x specifically), there are some compatibility problems.</p><p>The first= issue is that with LMDB 1.0, running either <code>postmap</code> or <c= ode>newaliases</code> now causes the following message</p><blockquote><= p>postmap: fatal: error updating lmdb:./aliases: MDB=5FBAD=5FTXN: Trans= action must abort, has a child, or is invalid</p></blockquote><p>I look= ed at it with GDB, the cause for this is a change in LMDB 1.0, namely t= his commit:</p><p><a href=3D"https://github.com/LMDB/lmdb/commit/d0fcfd= 3d02321d04b56a23e6c86c80309f4ecef5">ITS#8174 LMDB: fixes for mdb=5Fdrop= (MAIN=5FDBI) =C2=B7 LMDB/lmdb@d0fcfd3</a></p><p>Dropping the <code>MAIN= =5FDBI</code> now causes the transaction to be marked <code>MDB=5FTXN=5F= DIRTY</code> and <code>MDB=5FTXN=5FDROPPED</code>, which means any furt= her usage of the transaction that was used to drop <code>MAIN=5FDBI</co= de> will cause <code>MDB=5FBAD=5FTXN</code>.</p><p>For Postfix, all dat= abases are dropped by <code>slmdb=5Fprepare</code> with this statement:= <a href=3D"https://github.com/vdukhovni/postfix/blob/v3.11.4/postfix/s= rc/util/slmdb.c#L399">postfix/postfix/src/util/slmdb.c at v3.11.4 =C2=B7= vdukhovni/postfix</a></p><p>This causes <a href=3D"https://github.com/= LMDB/lmdb/blob/mdb.master3/libraries/liblmdb/mdb.c#L12544">lmdb/librari= es/liblmdb/mdb.c at mdb.master3 =C2=B7 LMDB/lmdb</a> to mark the transa= ction as dirty & dropped, and then when <code>slmdb=5Fput</code> is= called, it will call <code>mdb=5Fput</code> with the same transaction = handle here <a href=3D"https://github.com/vdukhovni/postfix/blob/master= /postfix/src/util/slmdb.c#L613">postfix/postfix/src/util/slmdb.c at mas= ter =C2=B7 vdukhovni/postfix</a> causing <code>MDB=5FBAD=5FTXN</code> t= o be returned from here <a href=3D"https://github.com/LMDB/lmdb/blob/md= b.master3/libraries/liblmdb/mdb.c#L11099">lmdb/libraries/liblmdb/mdb.c = at mdb.master3 =C2=B7 LMDB/lmdb</a> .</p><p>Now, I've made a temporary = fix for Arch: <a href=3D"https://gist.github.com/ChrisTX/731122de698a13= 497d808f8e0072310b">Postfix LMDB 1.0 fix</a> . </p><p>I'm not sure= this is the right approach, and it doesn't seem to fix all problems ye= t, as calling <code>newaliases</code> again on an already existing LMDB= now causes duplicate key warnings, so I don't think this is right or c= omplete just yet. My approach was to make <code>slmdb=5Fprepare</code> = to drop the database, then abort the transaction as is required, being = a new one, and then reopen the database with <code>mdb=5Fdbi=5Fopen</co= de>.</p><p>For reference, this is the downstream discussion at Arch: <a= href=3D"https://gitlab.archlinux.org/archlinux/packaging/packages/lmdb= /-/work=5Fitems/5">version 1.0.0 in testing breaks postfix (#5) =C2=B7 = Issue =C2=B7 archlinux/packaging/packages/lmdb</a> It covers LMDB 1.0 i= n general (other apps like bogofilter also have issues not yet identifi= ed), but the discussion regarding Postfix is in there, too.</p><p>But o= bviously, I would want to get this fixed upstream rather than doing any= downstream patching experiments.</p><p>Regards,</p><p>Christian Pfeiff= er</p></html> ------=_=-_OpenGroupware_org_NGMime-4283-1783006677.054223-3-------- --===============8941839574997696508== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Postfix-users mailing list -- [email protected] To unsubscribe send an email to [email protected] --===============8941839574997696508==--