Xa transaction not committed mysql

59 Views Asked by At

Im making XA transactions on mysql in a php script.

I am updating a table named 'test' on 2 different servers. ($connectionOne and $connectionTwo).

Only the first servers ($connectionOne) is getting updated when i 'commit' changes.

I don't see any examples online of multi server XA.

Any help would be very appreciated.

Regards Tommo

/*
 * 
 * make the database connections
 * 
 */
$connectionOne = databaseConnection(1,7, $Reconnect);
$connectionTwo = databaseConnection(1,8, $Reconnect);


//global id for the XA transaction
$xid_global='test';

//xid for connectionOne
$xid_connectionOne="'$xid_global','1'";

//xid for connectionTwo
$xid_connectionTwo="'$xid_global','2'";



//start XA on connection One
mysqli_query($connectionOne,"XA START $xid_connectionOne");
//update something
mysqli_query($connectionOne,"update test Set Field1='$V' WHERE Id='1'");



//start XA on connection Two
mysqli_query($connectionTwo,"XA START $xid_connectionTwo");
//update something
mysqli_query($connectionTwo,"update test Set Field2='$V' WHERE Id='1'");



/*finalise****************************************************/
mysqli_query($connectionOne,"XA END $xid_connectionOne");
mysqli_query($connectionOne,"XA PREPARE $xid_connectionOne");
//COMMIT or rollback
mysqli_query($connectionOne,"XA COMMIT $xid_connectionOne");
/***************************************************/
0

There are 0 best solutions below