Open rohit-nayak-ps opened 1 week ago
I'm not sure I follow the explanation:
The user decides then to drop some of the foreign key constraints
On the source or on the target? In my understanding this is on the target.
The related RowEvent has the foreign_key_checks ON because of the global setting.
Didn't the user just change the global setting to OFF
? So why would the even have FK checks ON
?
I feel like the problem here is that the user creates an inconsistency between target (where they dropped the constraints) and the source (where constraints still exist). Why would we expect revert replication to work in this scenario?
Overview of the Issue
In
MoveTables
imports for databases with foreign keys, after switching traffic, the reverse workflow breaks in some setups. One such is:MoveTables
import into a Vitess clusterFKManaged
mode and@@global.foreign_key_checks
areON
SwitchTraffic
. Now DMLs are running on the target and replicated on the source using the reverse workflow.@@global.foreign_key_checks
toOFF
expecting this to ignore the constraints. (They cannot drop the constraints since running alters could cause outages)RowEvent
has theforeign_key_checks
ON
because of the global setting.RowEvent
is applied on the source keyspace, in the reverse workflow,@@foreign_key_checks
is set toON
on the session (thus overriding the global setting). This results in the query failing because the constraints still exist on the source with a foreign key constraints failed error.