mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
* Notifications: deal with "Lock timeout exceeded" error on too many undeleted notifications
This commit is contained in:
parent
d7b6597076
commit
bd82a46b1f
@ -98,10 +98,10 @@ class notifications_push implements Json\PushBackend
|
||||
{
|
||||
if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
|
||||
|
||||
foreach((array)$account_id as $account_id)
|
||||
foreach((array)$account_id as $id)
|
||||
{
|
||||
self::$db->insert(self::TABLE, array(
|
||||
'account_id' => $account_id,
|
||||
'account_id' => $id,
|
||||
'notify_type' => self::TYPE,
|
||||
'notify_message' => json_encode(array(
|
||||
'method' => $key,
|
||||
@ -117,17 +117,36 @@ class notifications_push implements Json\PushBackend
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete push messages older then our heartbeat-limit (poll frequency of notifications)
|
||||
* Delete push messages older than our heartbeat-limit (poll frequency of notifications)
|
||||
*/
|
||||
protected static function cleanup_push_msgs()
|
||||
{
|
||||
if (($ts = self::$db->from_unixtime(Api\Session::heartbeat_limit())))
|
||||
{
|
||||
try {
|
||||
self::$db->delete(self::TABLE, array(
|
||||
'notify_type' => self::TYPE,
|
||||
'notify_created < '.$ts,
|
||||
), __LINE__, __FILE__, self::APP);
|
||||
}
|
||||
catch (Api\Db\Exception $e) {
|
||||
if ($e->getCode() == 1205) // MariaDB: Lock wait timeout exceeded
|
||||
{
|
||||
$n = 0;
|
||||
do {
|
||||
self::$db->delete(self::TABLE, array(
|
||||
'notify_type' => self::TYPE,
|
||||
'notify_created < '.$ts,
|
||||
), __LINE__, __FILE__, self::APP, null, 1000);
|
||||
}
|
||||
while($n++ < 100 && self::$db->affected_rows());
|
||||
}
|
||||
else
|
||||
{
|
||||
_egw_log_exception($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user