Periodically save last activity date data from Redis to the database
requested to merge 27790-periodically-save-last-activity-date-data-from-redis-to-the-database into master
This MR adds a cron worker that persists the last activity of users that were active the day before.
The cron is runs at 00:30 every day and loop per batch of 100 users (to avoid a too high query pressure).
The two first commits will be backported to CE.
What this MR does:
-
Backfill from latest last_activity_on
or firstcurrent_sign_in_at
-
Post-deployment migration migrates last_activity_on
from Redis, and fallback tocurrent_sign_in_at
andcreated_at
-
Tested on MySQL -
For ~1 million users (1/3 with activity in Redis, 1/3 with a current_sign_in_at
and 1/3 with acreated_at
, the migrations takes around ~3-4 minutes- Snippet used to create a lot of users with initial data to migrate: https://gitlab.com/gitlab-org/gitlab-ce/snippets/1655865
-
-
Migration approved by a DB/migration specialist -
Squash commits to be backported to CE into a few logical ones -
Backport some commits to CE
Closes gitlab-ce#27790