Page MenuHomePhabricator

Expire and garbage collect unused sessions
ClosedPublic

Authored by epriestley on Jan 15 2014, 9:40 PM.
Tags
None
Referenced Files
F14475795: D7976.id18046.diff
Fri, Dec 27, 9:02 PM
F14474627: D7976.id18046.diff
Fri, Dec 27, 4:09 PM
F14474626: D7976.id.diff
Fri, Dec 27, 4:09 PM
F14474625: D7976.id18048.diff
Fri, Dec 27, 4:09 PM
F14474522: D7976.diff
Fri, Dec 27, 3:52 PM
Unknown Object (File)
Fri, Dec 13, 4:01 PM
Unknown Object (File)
Thu, Dec 12, 8:07 AM
Unknown Object (File)
Sun, Dec 8, 1:02 PM
Subscribers

Details

Reviewers
btrahan
Maniphest Tasks
T4310: Allow external users to establish real sessions
Restricted Maniphest Task
Commits
Restricted Diffusion Commit
rPacb141cf52c1: Expire and garbage collect unused sessions
Summary

Ref T3720. Ref T4310. Currently, we limit the maximum number of concurrent sessions of each type. This is primarily because sessions predate garbage collection and we had no way to prevent the session table from growing fairly quickly and without bound unless we did this.

Now that we have GC (and it's modular!) we can just expire unused sessions after a while and throw them away:

  • Add a sessionExpires column to the table, with a key.
  • Add a GC for old sessions.
  • When we establish a session, set sessionExpires to the current time plus the session TTL.
  • When a user uses a session and has used up more than 20% of the time on it, extend the session.

In addition to this, we could also rotate sessions, but I think that provides very little value. If we do want to implement it, we should hold it until after T3720 / T4310.

Test Plan
  • Ran schema changes.
  • Looked at database.
  • Tested GC:
    • Started GC.
    • Set expires on one row to the past.
    • Restarted GC.
    • Verified GC nuked the session.
  • Logged in.
  • Logged out.
  • Ran Conduit method.
  • Tested refresh:
    • Set threshold to 0.0001% instead of 20%.
    • Loaded page.
    • Saw a session extension ever few page loads.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped