I have two database in mysql running with innoDB and the second db has foreign key related to primary key of the first one.
In my code I need to insert in the first DB and get id for that and insert to the second one.
All goes well unless I start transaction and that locks the first DB for the new ID and second one cannot insert that ID and I am getting
SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction
. When I remove foreign key then it goes fine.
I need to mention that I use PHP PDO to connect to MySql and I create separate connection to each DB and I also cannot commit the first db transaction so that second one goes through because I need to make sure all transactions to all dbs goes fine in whole process and then start committing them.
Thanks Ramin