Project

General

Profile

Actions

Feature #28952

closed

Update User#last_login_on only once per minute

Added by Holger Just almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Performance
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
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.


Files


Related issues

Related to Redmine - Defect #20648: Users' "Last connection" is not updated correctly.Closed

Actions
Related to Redmine - Feature #29041: Update session token only once per minuteClosedGo MAEDA

Actions
Actions #1

Updated by Go MAEDA almost 6 years ago

  • Target version set to Candidate for next major release
Actions #2

Updated by Pavel Rosický almost 6 years 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.

Actions #3

Updated by Go MAEDA almost 6 years ago

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

Updated by Go MAEDA almost 6 years 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.

Actions #5

Updated by Go MAEDA almost 6 years ago

  • Category set to Performance
Actions #6

Updated by Jean-Philippe Lang almost 6 years 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.

Actions #7

Updated by Pavel Rosický almost 6 years ago

done #29041

Actions #8

Updated by Marius BĂLTEANU almost 6 years ago

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

Also available in: Atom PDF