Answer the question
In order to leave comments, you need to log in
How to update a record that refers to another database (which is in a transaction at the moment)?
There are two databases: DB1, DB2.
And these databases are in the table: DB1.groups[id, name] and DB2.keywords[id, name, group_id].
DB1.groups.id is a foreign key for DB2.keywords.group_id
The task is: get data -> process -> update DB1.groups -> update DB2.keywords.
Implementation pseudocode:
//begin transaction for DB1;
begin_transaction('db1');
try {
$a = get_data()
$a = handle1($a);
insert_to_db1($a);
insert_to_db2($a); // вот тут и происходит завис запроса и ошибкой “Lock wait timeout exceeded; try restarting transaction”
commit_transaction('db1');
} catche(\Exception $e) {
rollback_transaction('db1');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question