Skip to content
Snippets Groups Projects
Commit 9b88eeac authored by catch's avatar catch
Browse files

Issue #1484216 by Berdir, beejeebus: Fixed Race condition in ...

Issue #1484216 by Berdir, beejeebus: Fixed Race condition in  _update_create_fetch_task() (PDO Exceptions).
parent c7c6b79d
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -237,12 +237,22 @@ function _update_create_fetch_task($project) {
if (empty($fetch_tasks[$cid])) {
$queue = queue('update_fetch_tasks');
$queue->createItem($project);
db_insert('cache_update')
->fields(array(
'cid' => $cid,
'created' => REQUEST_TIME,
))
->execute();
// Due to race conditions, it is possible that another process already
// inserted a row into the {cache_update} table and the following query will
// throw an exception.
// @todo: Remove the need for the manual check by relying on a queue that
// enforces unique items.
try {
db_insert('cache_update')
->fields(array(
'cid' => $cid,
'created' => REQUEST_TIME,
))
->execute();
}
catch (Exception $e) {
// The exception can be ignored safely.
}
$fetch_tasks[$cid] = REQUEST_TIME;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment