[livejournal] r16527: Added hack to load subscripitions from D...

Apr 12, 2010 10:55


Committer: vsukhanovAdded hack to load subscripitions from DB slave

U trunk/cgi-bin/LJ/Event.pm

Modified: trunk/cgi-bin/LJ/Event.pm
===================================================================
--- trunk/cgi-bin/LJ/Event.pm 2010-04-12 10:49:28 UTC (rev 16526)
+++ trunk/cgi-bin/LJ/Event.pm 2010-04-12 10:55:47 UTC (rev 16527)
@@ -555,8 +555,17 @@
# we got enough subs
last if $limit && $limit_remain <= 0;

- my $udbh = LJ::get_cluster_master($cid)
- or die;
+ ## hack: use inactive server of user cluster to find subscriptions
+ ## LJ::DBUtil wouldn't load in web-context
+ ## inactive DB may be unavailable due to backup, or on dev servers
+ ## TODO: check that LJ::get_cluster_master($cid) in other parts of code
+ ## will return handle to 'active' db, not cached 'inactive' db handle
+ my $udbh = eval {
+ require 'LJ/DBUtil.pm';
+ LJ::DBUtil->get_inactive_db($cid)
+ }
+ || LJ::get_cluster_master($cid);
+ die "Can't connect to db" unless $udbh;

# first we find exact matches (or all matches)
my $journal_match = $allmatch ? "" : "AND journalid=?";

vadvs, livejournal, pm

Previous post Next post
Up