Jump to content

Could Tracy cause this: "Error: Exception: Unable to obtain lock for session (retry in 30s)"


Recommended Posts

Posted

Good day, @adrian!

Today I am having some large traffic on a project. And there stated to appear a lot of 500 errors like this: Error:  Exception: Unable to obtain lock for session (retry in 30s). I have found this thread, turned off Tracy (which was id Development mode, but limited with tracy-debugger permission) and it seemed to help. Could you please explain if that is expected. Do we need to fix Tracy? Or the best practice is to have it off/in PRODUCTION mode on prod?

Thanks!

Posted

Hi Ivan - it looks like you are also running SessionHandlerDB (as mentioned by the folks in that other thread).

I have found many issues with Tracy and that module over the years so I don't run that module (except when testing) and haven't ever seen that error. 

For now (if you don't need it, I would suggest disabling that module), but I would like to see if @ryan has any ideas.

  • Like 1
Posted

Just speculating about the SessionHandlerDB link: could this be caused by locking on the session table if there's a long running process holding a connection open somehow?

  • Like 2
  • 2 weeks later...
Posted

Here's a newer version of my spin on SessionHandlerDB that should handle a couple of edge cases. Please let me know if this is an improvement for you.

Spoiler

Specifically, it releases locks

  • as many times as needed (in case session_reset() was called somewhere causing a second call to SessionHandler::read() - in which case the lock could be owned more than once by the same process, needing multiple releases.)
  • as part of the SessionHandler::destroy() method called from PHP's session_destroy() call or session_regenerate_id(true).

SessionHandlerDB.module

Posted
On 4/12/2023 at 11:12 PM, netcarver said:

...and keep an eye out for any new entries in the "session-errors" log file.

I have installed the modified module. But there was no records in session-errors logs file. In fact it has not even been created. And it didn't solve the issue as far as I can tell as the mentioned error didn't go away.

With Tracy turned off it appeared less often but still did.

I think that long and heavy DB queries do cause this.

Posted

Hello Ivan, thanks for trying that out - the session-errors log is only created if there's an issue obtaining a lock. If there are no issues, you won't see an entry there.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...