[livejournal] r23218: LJSUP-14114: Remove outdated user sessio...
Committer: vad
LJSUP-14114: Remove outdated user session in backgroundU trunk/bin/maint/clean_caches.pl U trunk/cgi-bin/LJ/Session.pm
Modified: trunk/bin/maint/clean_caches.pl
===================================================================
--- trunk/bin/maint/clean_caches.pl 2012-10-30 07:26:18 UTC (rev 23217)
+++ trunk/bin/maint/clean_caches.pl 2012-10-30 12:00:42 UTC (rev 23218)
@@ -184,6 +184,13 @@
}
print " deleted $cnt_delete\n";
+ print "-I- Remove outdated sessions.\n";
+ LJ::disconnect_dbs();
+ foreach my $c (@LJ::CLUSTERS) {
+ my $dbh = LJ::get_cluster_master($c);
+ $dbh->do("DELETE FROM sessions WHERE timeexpire < UNIX_TIMESTAMP() LIMIT 50000");
+ }
+
LJ::run_hooks('extra_cache_clean');
LJ::disconnect_dbs();
Modified: trunk/cgi-bin/LJ/Session.pm
===================================================================
--- trunk/cgi-bin/LJ/Session.pm 2012-10-30 07:26:18 UTC (rev 23217)
+++ trunk/cgi-bin/LJ/Session.pm 2012-10-30 12:00:42 UTC (rev 23218)
@@ -105,11 +105,6 @@
my $udbh = LJ::get_cluster_master($u);
return undef unless $udbh;
- # clean up any old, expired sessions they might have (lazy clean)
- $u->do("DELETE FROM sessions WHERE userid=? AND timeexpire < UNIX_TIMESTAMP()",
- undef, $u->{userid});
- # FIXME: but this doesn't remove their memcached keys
-
my $expsec = LJ::Session->session_length($exptype);
my $timeexpire = time() + $expsec;
