Answer the question
In order to leave comments, you need to log in
Distributed transaction not working in PHP + MySQL?
Good afternoon.
I happened to use distributed transactions in a php script. As far as I understand from the docks , having several connections to the database in each, we must open an XA transaction with a unique identifier, then complete it, prepare and commit.
those. looks like that:
[localhost] XA START 'tx-4f633bd5cfd9c7.06037054'
[192.168.56.10] XA START 'tx-4f633bd5cfd9c7.06037054'
[localhost] INSERT INTO `some_table` (field, value) VALUES ('field 191', '845')
[192.168.56.10] INSERT INTO `some_table` (field, value) VALUES ('field 191', '558')
[localhost] XA END 'tx-4f633bd5cfd9c7.06037054'
[localhost] XA PREPARE 'tx-4f633bd5cfd9c7.06037054
[192.168.56.10] Xa End 'TX-4F633BD5CFD9C7.06037054'
[192.168.56.10] Xa Prepare 'TX-4F633BD5CFD9C7.06037054'
[Localhost] XA Commit 'TX-4F633BD5CFD9C7.06037054'
[192.168.56.10] XA Commit 'TX- 4f633bd5cfd9c7.06037054'
LAST INT: 325
[localhost] XA START 'tx-4f633eb70ca183.03963688'
[192.168.56.10] XA START 'tx-4f633eb70ca183.03963688'
[localhost] INSERT INTO `some_table` (field, value) VALUES ('field 325', '818')
[192.168.56.10] INSERT INTO `some_table` (field, value) VALUES ('field 325', '677')
[localhost] XA END 'tx-4f633eb70ca183.03963688'
[localhost] XA PREPARE 'tx- Sleep .
_
_
Press enter…
Done. Committing.
[localhost] XA COMMIT 'tx-4f633eb70ca183.03963688'
[192.168.56.10] XA COMMIT 'tx-4f633eb70ca183.
[192.168.56.10] ERROR: MySQL server has gone away
LOCALHOST:
mysql> select * from some_table;
+----+-----------+-------+
| id | field | value |
+----+-----------+-------+
| 1 | field 325 | 818 |
+----+-----------+-------+
1 row in set (0.00 sec)
mysql> XA RECOVER;
Empty set (0.00 sec)
192.168.56.10
mysql> select * from some_table;
Empty set (0.00 sec)
mysql> xa recover;
Empty set (0.00 sec)
Answer the question
In order to leave comments, you need to log in
who knows…
try in this order:
[localhost] XA END 'tx-4f633bd5cfd9c7.06037054'
[192.168.56.10] XA END 'tx-4f633bd5cfd9c7.06037054'
[localhost] XA PREPARE 'tx-
4f633bd5cfd9c0.06 56.10] XA PREPARE 'tx-4f633bd5cfd9c7.06037054'
A two-phase commit basically protects against the fact that one of the participants violates the constraint and refuses to commit. He also experiences some other failures, but not the intervention of a person who set himself the task of breaking him.
Well, it looks like bugs.mysql.com/bug.php?id=12161 is also relevant to your question.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question