From: Naveed Massjouni Date: Fri, 9 May 2014 18:51:26 +0000 (-0700) Subject: Updated discard_changes docs regarding { force_pool => 'master' } X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3dd506b8d3671add7886c056b15a2c8a88c985e3;p=dbsrgits%2FDBIx-Class-Historic.git Updated discard_changes docs regarding { force_pool => 'master' } --- diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index cad0185..ce08fbd 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -1490,11 +1490,12 @@ $attrs, if supplied, is expected to be a hashref of attributes suitable for pass second argument to C<< $resultset->search($cond, $attrs) >>; Note: If you are using L as your -storage, please kept in mind that if you L on a row that you -just updated or created, you should wrap the entire bit inside a transaction. -Otherwise you run the risk that you insert or update to the master database -but read from a replicant database that has not yet been updated from the -master. This will result in unexpected results. +storage, a default of +L<< C<< { force_pool => 'master' } >> +|DBIx::Class::Storage::DBI::Replicated/SYNOPSIS >> is automatically set for +you. Prior to C<< DBIx::Class 0.08109 >> (before 2010) one would have been +required to explicitly wrap the entire operation in a transaction to guarantee +that up-to-date results are read from the master database. =cut diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 3c58716..fc10c75 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -1080,7 +1080,8 @@ sub _get_server_version { Due to the fact that replicants can lag behind a master, you must take care to make sure you use one of the methods to force read queries to a master should you need realtime data integrity. For example, if you insert a row, and then -immediately re-read it from the database (say, by doing $result->discard_changes) +immediately re-read it from the database (say, by doing +L<< $result->discard_changes|DBIx::Class::Row/discard_changes >>) or you insert a row and then immediately build a query that expects that row to be an item, you should force the master to handle reads. Otherwise, due to the lag, there is no certainty your data will be in the expected state.