简体   繁体   中英

MySQL Master <-> Slave, PDO , Zend Framework and Transactions

We have some wired problems with the following structure:

  • Zend Framework 1
  • MySQL 5 Master <-> Slave replication
  • PDO (Zend) Transactions

Example:

Query 1

 $adapter->beginTransaction():      
 $where = $adapter->quoteInto('ID = ?', $id);
 $adapter->update()...
 $adapter->commit();

Query 2

 $adapter->beginTransaction():      
 $where = $adapter->quoteInto('ID = ?', $id);
 $adapter->update()...
 $adapter->commit();

When started on an non cluster mysql server everything works fine. When started on an replicated enviorment we get the following exception:

There is no active transaction

Now i have added:

$adapter->closeConnection();

after the first query, voila it works on the cluster. Removed it : and it is still working...

Cant explain this, maybe an unclosed transaction? or normal behavoir?

Do you have a plugin that ensures that the connections are closed on every http request? I used to have weird behaviors with zend and dbs because the connections were remaining open.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM