phpmysqldistributed-transactionscross-server

Is there a way to put several SQL to diffrente servers inside the same transaction?


In my system we do action, and for reporting sake we log that action on another server (star schema if it interests). Obviously I need the action updates/inserts be in the same transaction as the logging.
So, is there a way to include two different sqls to two different servers in the same transaction?
Right now I manage that in the code level (php)


Solution

  • This isn't possible with MySQL alone. While MySQL does have a Federated Storage Engine (ie: remote access to other MySQL servers) it doesn't support transactions. That means you can't coordinate a multi-server transaction directly through MySQL. MySQL does support XA for InnoDB tables, so you can use an external transaction manager with MySQL, but PHP doesn't have any support for XA. Generally this is considered an Enterprise-level feature, and you'd implement using Java or C#/.NET.