diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php index 8f1b8e6d75f48..c02220c244200 100644 --- a/lib/private/DB/Adapter.php +++ b/lib/private/DB/Adapter.php @@ -103,7 +103,10 @@ public function insertIfNotExist($table, $input, ?array $compare = null) { $query .= ' HAVING COUNT(*) = 0'; try { - return $this->conn->executeUpdate($query, $inserts); + $this->conn->beginTransaction(); + $rows = $this->conn->executeUpdate($query, $inserts); + $this->conn->commit(); + return $rows; } catch (UniqueConstraintViolationException $e) { // This exception indicates a concurrent insert happened between // the insert and the sub-select in the insert, which is safe to ignore.