Skip to content

Preserve LMDB databases across an on-disk format change - #2405

Open
nickanderson wants to merge 2 commits into
cfengine:masterfrom
nickanderson:CFE-4701/master
Open

Preserve LMDB databases across an on-disk format change#2405
nickanderson wants to merge 2 commits into
cfengine:masterfrom
nickanderson:CFE-4701/master

Conversation

@nickanderson

@nickandersonnickanderson commented Aug 6, 2026

Copy link
Copy Markdown
Member

Dumps the LMDB databases in the preinstall script using the old mdb_dump and reloads them in the postinstall script using the new mdb_load, so upgrading across an LMDB on-disk format change no longer leaves them looking corrupt and gets them deleted. Gated on an LMDB_VERSION comparison, so it is a no-op unless the major.minor series actually changes.

Windows needs its own path, since the MSI runs none of those scripts: packaging/cfengine-nova/lmdb-migrate.cmd, driven by custom actions in cfengine-nova.wxs.

Worth knowing for review: the deployment-test host lists and the mass.py platform matrix contain no Windows entries, so the Windows half is not exercised by CI. It was validated manually with a real msiexec major upgrade on Windows Server 2019.

Ticket: CFE-4701

🤖 Generated with Claude Code

LMDB 1.0 cannot read databases written by 0.9, and reports them as
MDB_INVALID, which CFEngine treats as corruption and deletes. Export the
databases in the preinstall script while the old mdb_dump is still
installed, and import them again in the postinstall script.
Ticket: CFE-4701
Changelog: LMDB databases in the state directory are now preserved when upgrading across an LMDB on-disk format change, instead of being discarded as corrupt
The MSI runs none of the shell install scripts, so it needs its own migration.
InstallFiles overwrites mdb_dump.exe in place, so a custom action copies the old
one aside after StopServices and a second one migrates after InstallFiles.
Ticket: CFE-4701
Changelog: LMDB databases are now preserved when upgrading the Windows agent across an LMDB on-disk format change
@nickanderson

Copy link
Copy Markdown
MemberAuthor

Deployment tests pass: pr-pipeline #14421 -> sequential-tests #703 green (150 min), including 13-upgrade-minor (3.27.1 -> 3.29.0a) and 15-upgrade-triple (3.24.4 -> 3.27.1 -> 3.29.0a), both of which cross the LMDB 0.9 -> 1.0 format change.

The job does not archive the install logs, so this shows the upgrades succeed, not the dump/reload output itself.

https://ci.cfengine.com/job/sequential-tests/703/

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@nickanderson