I'm getting Session: Error while trying to free lock for ci_session show up in the error log a couple times a minute, sometimes, and every 15 minutes other times. Using Redis for sessions. It's not happening on a different server that has almost the same code base and is sharing the same Redis server, albeit with a different session name.

I'm using session_write_close() on every page as soon as I'm done handling sessions.

Switched to file-based sessions and it's not happening either.

Those links appear to be related to native PHP sessions. Codeigniter rolls its own session library that implements locking differently than native PHP does.

The bugs I linked to are present in the PHP Redis driver, phpredis.

CodeIgniter's Sessions functionality uses it to connect to Redis. There is even a caveat in the documentation stating

Since Redis doesn’t have a locking mechanism exposed, locks for this driver are emulated by a separate value that is kept for up to 300 seconds.

Ah, thanks. I think my problem is I have a race condition with some AJAX. I'm initiating a request before a previous request completes. However, I'm using session_write_close() immediately after retrieving session data when the script first runs, so it should be releasing the lock before doing any heavy lifting.