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'];
|
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(
|
self::$db->insert(self::TABLE, array(
|
||||||
'account_id' => $account_id,
|
'account_id' => $id,
|
||||||
'notify_type' => self::TYPE,
|
'notify_type' => self::TYPE,
|
||||||
'notify_message' => json_encode(array(
|
'notify_message' => json_encode(array(
|
||||||
'method' => $key,
|
'method' => $key,
|
||||||
@ -117,16 +117,35 @@ 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()
|
protected static function cleanup_push_msgs()
|
||||||
{
|
{
|
||||||
if (($ts = self::$db->from_unixtime(Api\Session::heartbeat_limit())))
|
if (($ts = self::$db->from_unixtime(Api\Session::heartbeat_limit())))
|
||||||
{
|
{
|
||||||
self::$db->delete(self::TABLE, array(
|
try {
|
||||||
'notify_type' => self::TYPE,
|
self::$db->delete(self::TABLE, array(
|
||||||
'notify_created < '.$ts,
|
'notify_type' => self::TYPE,
|
||||||
), __LINE__, __FILE__, self::APP);
|
'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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,4 +172,4 @@ class notifications_push implements Json\PushBackend
|
|||||||
return array_unique($online);
|
return array_unique($online);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifications_push::init_static();
|
notifications_push::init_static();
|
Loading…
Reference in New Issue
Block a user