{"record":{"id":"96691517bec24ea0","repo":"openmediavault/openmediavault","slug":"the-package-archive-is-held-by-another-process-please-try","errorCode":null,"errorMessage":"The package archive is held by another process. Please try again later.","messagePattern":"The package archive is held by another process\\. Please try again later\\.","errorType":"exception","errorClass":"OMV\\AssertException","httpStatus":null,"severity":"warning","filePath":"deb/openmediavault/usr/share/php/openmediavault/system/apt.inc","lineNumber":55,"sourceCode":"     * @throw \\OMV\\AssertException\n     */\n    public static function assertNotLocked(): void\n    {\n        if (is_locked(\"/var/lib/dpkg/lock\")) {\n            throw new \\OMV\\AssertException(\n                \"The package database is held by another process. \".\n                \"Please try again later.\"\n            );\n        }\n        if (is_locked(\"/var/lib/apt/lists/lock\")) {\n            throw new \\OMV\\AssertException(\n                \"The storage area for state information for each \".\n                \"package resource is held by another process. \".\n                \"Please try again later.\"\n            );\n        }\n        if (is_locked(\"/var/cache/apt/archives/lock\")) {\n            throw new \\OMV\\AssertException(\n                \"The package archive is held by another process. \".\n                \"Please try again later.\"\n            );\n        }\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":62,"githubUrl":"https://github.com/openmediavault/openmediavault/blob/dce610eb66f624c640d0eb7ce401ddd65b763520/deb/openmediavault/usr/share/php/openmediavault/system/apt.inc#L37-L62","documentation":"Thrown by \\OMV\\System::assertIsNotLocked() (apt state check) when the exclusive flock on /var/cache/apt/archives/lock is held by another process, meaning an apt/dpkg operation is concurrently modifying the package archive cache. The library raises this preemptively so callers fail fast instead of hanging or corrupting apt state. It is a transient contention error, not a configuration problem.","triggerScenarios":"Calling \\OMV\\System::assertIsNotLocked() (or any API that invokes it, e.g. update/upgrade/install helpers in \\OMV\\System\\Apt) while another process (apt-get, aptitude, unattended-upgrades, omv-aptclean, a previous OMV task) holds /var/cache/apt/archives/lock.","commonSituations":"Scheduled unattended-upgrades running while the web UI triggers a plugin install; two OMV UI update requests racing; a hung apt-get from an earlier failed run still holding the lock; a cron job and manual CLI apt invocation overlapping.","solutions":["Wait for the other apt process to finish and retry the operation","Identify the lock holder: check `fuser -v /var/cache/apt/archives/lock` or `lsof /var/cache/apt/archives/lock` and stop/kill it if stale","Disable or reschedule unattended-upgrades / OMV scheduled update tasks to avoid overlap","Only as a last resort for a dead process, remove stale lock files (/var/cache/apt/archives/lock) after confirming no apt/dpkg process is running"],"exampleFix":"// before: fire-and-forget call fails under lock contention\n$omvSystem->update();\n\n// after: poll for lock release, then act\nwhile (is_locked('/var/cache/apt/archives/lock')) {\n    sleep(5);\n}\n$omvSystem->update();","handlingStrategy":"retry","validationCode":"<?php\nif (is_locked('/var/cache/apt/archives/lock') ||\n    is_locked('/var/lib/dpkg/lock-frontend')) {\n    // defer the operation; another apt/dpkg run is active\n}","typeGuard":"null","tryCatchPattern":"try {\n    $system->assertIsNotLocked();\n    $system->update();\n} catch (\\OMV\\AssertException $e) {\n    sleep(30); // or log & reschedule\n}","preventionTips":["Check lock files before invoking apt via the library","Serialize all apt operations through a single queue/task runner","Disable or stagger unattended-upgrades relative to OMV tasks","Retry with backoff rather than failing the whole request"],"tags":["apt","lock-contention","dpkg","php"],"backgroundTag":"resource-already-locked","analyzedSha":"dce610eb66f624c640d0eb7ce401ddd65b763520","analyzedAt":"2026-09-15T09:48:09.960Z","contentChangedAt":"2026-09-15T09:48:09.960Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}