admin管理员组

文章数量:1025278

I'm working with two servers MariaDB with galera replication and MaxScale rw router.
One server takes write queryies only, the other one just selects.

I have this sequence of operations:

  • start transaction with propagation REQUIRES_NEW and isolation READ_COMMITTED
  • insert new record in tableA and get ID
  • insert new record in tableB using previous inserted ID as foreign key to tableA
  • commit
  • fails with Error: 1451-23000: Cannot delete or update a parent row: a foreign key constraint fails

This is not a systematics issue; most times it works without error, but a few times it fails. It may be connected to replication; that answers why most times it works and why the issue is thrown after the commit.

What I'm missing?

The issue doesn't arise from the master-write database because it is the database of the first tableA insertion. It is more likely the issue comes from the second server at replication time.

But since the transaction is unique and the replication works by entire transactions, how is it possibile that the foreign key doesn't work?

I'm working with two servers MariaDB with galera replication and MaxScale rw router.
One server takes write queryies only, the other one just selects.

I have this sequence of operations:

  • start transaction with propagation REQUIRES_NEW and isolation READ_COMMITTED
  • insert new record in tableA and get ID
  • insert new record in tableB using previous inserted ID as foreign key to tableA
  • commit
  • fails with Error: 1451-23000: Cannot delete or update a parent row: a foreign key constraint fails

This is not a systematics issue; most times it works without error, but a few times it fails. It may be connected to replication; that answers why most times it works and why the issue is thrown after the commit.

What I'm missing?

The issue doesn't arise from the master-write database because it is the database of the first tableA insertion. It is more likely the issue comes from the second server at replication time.

But since the transaction is unique and the replication works by entire transactions, how is it possibile that the foreign key doesn't work?

本文标签: