DBD::Multiplex, mysql replication and transactions



Hi all,

We've just setup MySQL replication, using the example from the DBD::Multiplex pod to connect to the master and slaves. This works beautifully: writes go to the master, and reads go to the slaves.

But now I'm running into an issue with transactions. The problem is that newly created records aren't replicated to the slaves until the transaction is commited. This in turn means that I can't do SELECTs on those records from inside the transaction.

Now, I fully understand why this happens, and how. Each part of the process makes perfect sense. But, I need a quick fix to DBD::Multiplex, so that it performs SELECTS on the master during a transaction.

I took a quick stroll through the source code, and I believe the following change may do the trick:

# change line 151 (version 1.98) from
if ($parent_handle->{'mx_master_id'} && &DBD::Multiplex::mx_is_modify_statement(\$statement)) {

# to
if ($parent_handle->{'mx_master_id'} && ( &DBD::Multiplex::mx_is_modify_statement(\$statement) or $parent_handle->{AutoCommit}==0 )) {


Can anybody confirm that this is a sensible change to make? Or is there a better way to notice an ongoing transaction?

Oh, I do realise that this probably isn't a general patch. But I do believe it would be useful to have some mechanism for dealing with transactions. In my case transactions need to go through the master handle. In other situations, there probably should be something that binds transactions to a specific handle as well.

Thoughts?

Rhesa
.



Relevant Pages

  • Re: DBD::Multiplex, mysql replication and transactions
    ... We've just setup MySQL replication, ... pod to connect to the master and slaves. ... But now I'm running into an issue with transactions. ...
    (perl.dbi.users)
  • DBD::Multiplex, mysql replication and transactions
    ... We've just setup MySQL replication, using the example from the DBD::Multiplex ... pod to connect to the master and slaves. ... But now I'm running into an issue with transactions. ...
    (perl.dbi.users)
  • Re: [RFC/PATCH 0/22] W1: sysfs, lifetime and other fixes
    ... defined in family driver. ... Bus master driver - is like NIC driver, it does not know about the rest ... It has it's logical slaves, it has it's own attributes and features, ... This is wrong - netlink notification is used and will be moved to ...
    (Linux-Kernel)
  • Re: tcl and threads: installing and other info
    ... So I'd like to parallelise the notification processing. ... a event based master process using ... more stable in case one of the slaves crashes or does nasty things. ... If you don't have enough memory for the database to do its ...
    (comp.lang.tcl)
  • Re: Two Way Bidirectional Rep
    ... transactional replication is generated, ... the replication engine actually uses to issue the transactions against the ... > use master ... > exec sp_adddistpublisher ...
    (microsoft.public.sqlserver.replication)