Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-71024

Disconnect from database while waiting for session lock

    • 10

      On installations with a large number of concurrent users a common problem is lock contention for the session write lock. As a consequence a lot of requests may end up waiting on a session write lock. While doing so they keep the database connection open which is opened at the beginning of handling a request. As waiting for a session lock can take several seconds or depending on config even minutes (think that's the default), this can lead to database problems due to the large number of open connections.

      Installing tools like ProxySQL or PgBouncer on the webservers can help alleviate some of this problem, but to avoid a tipping point this patch proposes to disconnect from the database entirely if the wait for the session lock has gone on for 2 seconds, and reconnects to the database once the session lock has been acquired.

      The current patch only implements this behavior for the redis session handler and mysqli_native. So if there is interest one could add support for the same behavior to other session handlers and database systems, although the code works as-is on all systems and simply does not do the reconnect if it is not supported by the underlying database system.

            Unassigned Unassigned
            naderman Nils Adermann
            Votes:
            12 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day
                1d

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.