From 084177a20c194767f227edb61acef236f99061f8 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 31 Mar 2020 19:57:05 +0200 Subject: Avoid multiple run of expiry procedure on large sites --- Zotlabs/Daemon/Expire.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 398425861..bce512b6d 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -9,6 +9,13 @@ class Expire { cli_startup(); + if ($pid = get_xconfig(0, 'expire', 'procid', false)) { + logger('Expire: procedure already run with PID ' . $pid); + return; + } + + set_xconfig(0, 'expire', 'procid', getmypid()); + // perform final cleanup on previously delete items $r = q("select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s", @@ -90,5 +97,7 @@ class Expire { logger('Expire: sys: done', LOGGER_DEBUG); } + + del_xconfig(0, 'expire', 'procid'); } } -- cgit v1.2.3