I am having a problem with concurrency when using MySQL and PHP + Propel 1.3. The following is a small example of the save method of the Propel object.
public function save(PropelPDO $con = null) {
$con = Propel::getConnection();
try {
$con->beginTransaction();
sleep(3);
parent::save($con);
$foo = $this->getFoo();
$foo->save($con);
$con->commit();
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
}
The problem is the $ foo object. Let them say that in a short period of time we get two method calls one by one. In some cases, if the second transaction reads $ foo ...
$foo = $this->getFoo();
... before the first transaction was able to save it ...
$foo->save($con);
... the $ foo read by the second transaction will be deprecated and bad things will happen.
How can I force lock objects on the Foo table so that subsequent transactions can only read from it after the first has completed its work?
EDIT: - -. , , ( $foo). . , $foo ( ). $foo, , .