Skip to content

Commit

Permalink
Better detection if a full history sync is needed in a multi-process …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
thomasjfox authored and mrubinsk committed Jun 5, 2015
1 parent d4db576 commit f1ed9e1
Showing 1 changed file with 19 additions and 5 deletions.
Expand Up @@ -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.
Expand Down

0 comments on commit f1ed9e1

Please sign in to comment.