Repository navigation
fix(backup): skip ephemeral coordinator lock databases - #119792
ayaangazali wants to merge 1 commit into
Conversation
A running gateway holds gateway.<hash>.lock.sqlite open, so compaction fails and no archive is produced. The exclusion list already covered reindex locks; extend it to the .lock.sqlite coordinators. Fixes openclaw#119757.
|
Thanks for independently tracing the lock-database failure. Closing this in favor of #119782, which was already open for #119757 and owns the canonical repair. This patch’s global #119782 limits exclusion to exact gateway/device coordinator basenames inside the authoritative CLI and managed-service lock directories, while preserving durable lock-named and coordinator-shaped databases elsewhere. The regression shapes here are already covered more strongly there, including a real held gateway coordinator, verification, sidecars, and durable lookalike preservation, so there is no test to transplant. #119782 is still awaiting publication of its exact-head ClawSweeper review. #119757 will remain open until the canonical fix lands. |
What Problem This Solves
Fixes #119757.
openclaw backup create --output <dir> --verifycannot back up a running gateway. It fails on a zero-byte ephemeral lock database the gateway holds open:No archive is produced, so the documented pre-upgrade backup step cannot run without stopping the gateway first, which the docs never say.
Refusing an unsafe raw copy is correct, and I did not touch that. The bug is that the file is in the backup set at all. It is a process-lifetime coordination lock, not user data:
src/infra/gateway-lock.ts:491acquires the coordinator as`${lockPath}.sqlite`overgateway.<hash>.lock, producing exactly thegateway.<hash>.lock.sqlitein the report.src/infra/device-identity-coordinator.ts:48buildsdevice-identity.<hash>.lock.sqlitethe same way.Why This Change Was Made
The repo already has the right mechanism, and this class of file was already understood to be non-backup material.
SQLITE_BACKUP_EXCLUDED_SUFFIXESinsrc/infra/backup-create.tsis a suffix list consulted both when classifying a source path and when walking directories. It listed.reindex-lock.sqliteand nothing else, so reindex locks were skipped while coordinator locks were not.So this adds one entry rather than inventing an exclusion path:
That covers the gateway config and state locks and the device-identity lock. The existing entry has to stay, because
.reindex-lock.sqliteends in-lock.sqlitewith a hyphen and would not match the new suffix.I chose the suffix over excluding
tmp/wholesale. The suffix targets the actual property that makes these files unbackupable, which is that they are exclusive coordinators held for the life of a process, and it keeps working if a coordinator is ever placed outsidetmp/, as the device-identity one already is.User Impact
backup createworks against a running gateway again, which is the documented pre-upgrade path. Nothing that belongs in a backup is dropped: these files carry no durable state, are zero-byte in the reported case, and are recreated on demand by whichever process next takes the lock.No config, schema, or default surface changes. Production delta is +5/-1 in one file, four of which are the comment explaining why the entry exists.
Evidence
Regression coverage in
src/infra/backup-create.test.ts, added as a sibling to the existing transient-reindex exclusion test so both live in the same place. It writes the real path shapes a running gateway leaves behind, including the sidecars:each with
"",-wal,-shm, and-journal, then asserts none appear in the produced archive.I confirmed the test pins the fix by reverting the suffix list to its previous value and rerunning:
then restored it for 70/70.
Verification:
src/infra/backup-create.test.ts70 tests,src/commands/backup3 files / 16 tests,tsgo -p tsconfig.core.jsonandtsgo -p test/tsconfig/tsconfig.core.test.jsonboth clean,git diff --checkclean.I did not reproduce the original failure end to end against a live gateway, since that means holding the operator's running service open, which the repo rules put off limits without explicit approval. The test reproduces the file shape and the archive assertion instead, and the lock-path construction is cited above rather than assumed.
AI-assisted: written with AI assistance. I read the backup classifier, the directory walk, the gateway lock acquisition, and the device-identity coordinator myself before changing anything.