January 16th, 2002

new get_dbh

Good news: a new kick-ass get_dbh is now in CVS.

Properties of new kick-ass get_dbh():

  • two layer cache (role to DSN, and DSN to handle).... no duplicate connections to same db for different roles. (as noted earlier, this hasn't been a problem yet, but would've, with cluster1 and master going to be on the same server initially)
  • dead db tracking. if a server is down for maintenance or whatever, the code doesn't return that dead db handle ... instead, it pretends like it doesn't exist and picks another randomonly (with weighting, still). when the server is back alive, it'll be reconsidered for usage later. Best part: site keeps on working smooth if a DB dies in the middle of the night.
  • idle connection killing. connections that aren't used in a few minutes are disconnected.
  • no complicated inheritance logic. you have to explicitly request the roles you want now. if you want a read-only connection: my $dbh = LJ::get_dbh("slave", "master"). just giving "slave" is like what doing "slave!" was before, a request to ONLY get a slave, never a master. there is no longer any exclamation mark logic. on that code will shortly die here.... only a few spots.
  • new function LJ::use_diff_db($role1, $role2) which returns true if the two roles are served by separate databases for sure. this is useful for moveucluster.pl, which doesn't want to delete from a db, insert in other, and delete from source, if those were the same DB.
Anyway, glad this is done. So much better than before.

I'm moving on now to the final stretch of the cluster stuff, which depended on this get_dbh re-write.

Patch pause, por favor...

I applied a bunch of people's patches today. But it's getting to be a pain, as certain parts of my local tree are much different, which means I have to apply them once to the CVS version, and once to my own almost-clustering version.

So for a week, hold on the patches unless it's small and/or important.... Thanks.

BTW, if you post a patch and I don't see it or don't reply, don't think that means it sucks or I don't want it .... keep mentioning it until you get feedback, from somebody. I generally don't apply a patch until I've seen that it's been tested by others and there's general approval for it.

Party break!

lastn pages are now loading either from the old schema or from clusters on my test server and 3 separate databases!

rock rock rock.!!!!

i'll commit a bunch tonight. the other views should be faster now that i've done so much infrastructure work.