{"record":{"id":"c3f406d70cc57b88","repo":"phalcon/cphalcon","slug":"could-not-acquire-the-session-lock-with-key-lock","errorCode":null,"errorMessage":"Could not acquire the session lock with key: {lockKey}","messagePattern":"Could not acquire the session lock with key: (.+?)","errorType":"exception","errorClass":"Phalcon\\Session\\Adapter\\Exceptions\\AdapterRuntimeError","httpStatus":null,"severity":"error","filePath":"phalcon/Session/Adapter/Redis.zep","lineNumber":111,"sourceCode":"     */\n    public function destroy(string id) -> bool\n    {\n        var result;\n\n        let result = parent::destroy(id);\n\n        this->releaseLock();\n\n        return result;\n    }\n\n    /**\n     * Read\n     */\n    public function read(string id) -> string\n    {\n        if (true === this->lockingEnabled && true !== this->acquireLock(id)) {\n            throw new AdapterRuntimeError(\n                \"Could not acquire the session lock with key: \" . this->lockKey\n            );\n        }\n\n        return parent::read(id);\n    }\n\n    /**\n     * Tries to acquire the session lock, pausing `lockWaitTime` microseconds\n     * between attempts, up to `lockRetries` times\n     */\n    protected function acquireLock(string id) -> bool\n    {\n        var client, lockKey, result, token;\n        int attempt;\n\n        let lockKey = this->prefix . id . \"-lock\";\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Session/Adapter/Redis.zep#L93-L129","documentation":"Session locking failure in Redis session adapter: read() tried to acquire a per-session lock (lockingEnabled is true) but acquireLock() did not return true after retrying for lockRetryInterval over the lockWaitTime budget. Another request holds the lock for the same session id, or a stale lock was never released; instead of corrupting concurrent session data, the adapter aborts with this runtime error naming the lock key.","triggerScenarios":"Thrown at phalcon/Session/Adapter/Redis.zep:111 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure every request path releases the lock (destroy/close/releaseLock) so stale locks do not persist","Increase the 'lockWaitTime' and/or 'lockRetryInterval' options for long-running requests","Check for stuck/duplicated requests hitting the same session id (e.g. parallel AJAX calls)","Inspect the Redis key for the lock and clear it manually if a crashed process left it behind"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","contentChangedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}