From: Caleb Cushing Date: Thu, 2 Feb 2012 21:25:44 +0000 (-0600) Subject: remove stale link and doc readonly pool queries X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d7c37d66e40b2110e84773fa8fceaa8c245656bf;p=dbsrgits%2FDBIx-Class-Historic.git remove stale link and doc readonly pool queries transactions cause an implicit force to master, this documents how you can override this to force to pool Signed-off-by: Caleb Cushing --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 615db2b..caa8a49 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -506,6 +506,8 @@ willert: Sebastian Willert wreis: Wallace Reis +xenoterracide: Caleb Cushing + yrlnry: Mark Jason Dominus zamolxes: Bogdan Lucaciu diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 05b6e19..1b50a46 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -56,9 +56,9 @@ be delegated to the replicants, while writes to the master. You can force a given query to use a particular storage using the search attribute 'force_pool'. For example: - my $RS = $schema->resultset('Source')->search(undef, {force_pool=>'master'}); + my $rs = $schema->resultset('Source')->search(undef, {force_pool=>'master'}); -Now $RS will force everything (both reads and writes) to use whatever was setup +Now $rs will force everything (both reads and writes) to use whatever was setup as the master storage. 'master' is hardcoded to always point to the Master, but you can also use any Replicant name. Please see: L and the replicants attribute for more. @@ -68,8 +68,12 @@ force read traffic to the master. In general, you should wrap your statements in a transaction when you are reading and writing to the same tables at the same time, since your replicants will often lag a bit behind the master. -See L for more help and -walkthroughs. +If you have a multi-statement read only transaction you can force it to select +a random server in the pool by: + + my $rs = $schema->resultset('Source')->search( undef, + { force_pool => $db->storage->read_handler->next_storage } + ); =head1 DESCRIPTION