Feature #28952

Update User#last_login_on only once per minute

Added by Holger Just 18 days ago. Updated 6 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Performance
Target version:4.0.0
Resolution:Fixed

Description

On setups where a lot of logins happen (e.g. when heavily using the API with Basic Auth credentials), access to the@ users@ table can get contentioned due to the many parallel write queries to the table during each request as each requests sets the last_login_on column of the user to the current date in User.try_to_login. This can result in deadlocks or general long lock waits on the database since all of these update queries will effectively be serialized per user.

By updating the last_login_on column less often, we can drastically reduce this contention. The attached patch implements this by only updating the last_login_on column once per minute.

0001-Update-User-last_login_on-only-once-per-minute-and-u.patch Magnifier (1.45 KB) Holger Just, 2018-06-05 10:18


Related issues

Related to Redmine - Defect #20648: Users' "Last connection" is not updated correctly. New
Related to Redmine - Feature #29041: Update session token only once per minute New

Associated revisions

Revision 17403
Added by Jean-Philippe Lang 6 days ago

Update User#last_login_on only once per minute and user to reduce DB lock contention on users table (#28952).

Patch by Holger Just.

History

#1 Updated by Go MAEDA 18 days ago

  • Target version set to Candidate for next major release

#2 Updated by Pavel Rosický 18 days ago

nice catch!

I'm wondering if something like this could be also applied for
verify_session_token - https://github.com/redmine/redmine/blob/43d9bea7c5da32a99c3ebdb828e23d6a02c31c12/app/models/user.rb#L442
if Rails.application.config.redmine_verify_sessions is enabled, redmine updates user tokens on each request. These updates are at the top or our db monitoring.

#3 Updated by Go MAEDA 18 days ago

  • Related to Defect #20648: Users' "Last connection" is not updated correctly. added

#4 Updated by Go MAEDA 16 days ago

  • Target version changed from Candidate for next major release to 4.1.0

+1
Sometimes I also experience the same problem.

Setting target version to 4.1.0.

#5 Updated by Go MAEDA 14 days ago

  • Category set to Performance

#6 Updated by Jean-Philippe Lang 6 days ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version changed from 4.1.0 to 4.0.0
  • Resolution set to Fixed

Patch committed, thanks.

Pavel Rosický wrote:

I'm wondering if something like this could be also applied for
verify_session_token - https://github.com/redmine/redmine/blob/43d9bea7c5da32a99c3ebdb828e23d6a02c31c12/app/models/user.rb#L442
if Rails.application.config.redmine_verify_sessions is enabled, redmine updates user tokens on each request. These updates are at the top or our db monitoring.

Please fill a separate issue so we can keep track of that.

#7 Updated by Pavel Rosický 6 days ago

done #29041

#8 Updated by Marius BALTEANU 6 days ago

  • Related to Feature #29041: Update session token only once per minute added

Also available in: Atom PDF