From f1ed9e130b2a240e8db38d3150795ae1bb75fc35 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Thu, 22 Aug 2013 17:38:05 +0200 Subject: [PATCH] Better detection if a full history sync is needed in a multi-process environment If our stored 'last_sync' timestamp is newer than the logged 'sync' action in the history database, the last history update aborted for some reason. If the 'sync' action from the history database is newer, it means our in-memory version of the data_cache was outdated and already updated by another process. --- .../Storage/Data/Query/History/Cache.php | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data/Query/History/Cache.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data/Query/History/Cache.php index 69e52bd92ea..7b875930a24 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data/Query/History/Cache.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data/Query/History/Cache.php @@ -46,13 +46,27 @@ public function synchronize($params = array()) { $timestamp_key = 'Kolab_History_Sync:'.$this->data->getId(); + /** + * Check if we need to do a full synchronization. If our stored 'last_sync' + * timestamp is newer than the logged 'sync' action in the history database, + * the last history update aborted for some reason. + * + * If the 'sync' action from the history database is newer, it means + * our in-memory version of the data_cache was outdated + * and already updated by another process. + */ if (isset($params['last_sync']) && ($params['last_sync'] === false || - $params['last_sync'] !== $this->history->getActionTimestamp($timestamp_key, 'sync'))) { - /** - * Ignore current changeset and do a full synchronization as we are - * out of sync - */ + $params['last_sync'] > $this->history->getActionTimestamp($timestamp_key, 'sync'))) + { + $folder_id = $this->data->getIdParameters(); + unset($folder_id['type']); + + Horde::log(sprintf('Resyncing Horde_History for Kolab: last_sync: %d, logged sync: %d, folder. %s', + $params['last_sync'], + $this->history->getActionTimestamp($timestamp_key, 'sync'), + print_r($folder_id, true)), 'WARN'); + unset($params['changes']); } // Sync. Base class takes care of UIDVALIDITY changes.