Projects
Kolab:16:Testing:Candidate
kolab-syncroton
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 12
View file
kolab-syncroton-2.4.0.tar.gz/lib/ext/Syncroton/Command/Sync.php
Changed
@@ -664,7 +664,8 @@ // fetch entries added since last sync $allClientEntries = $this->_contentStateBackend->getFolderState( $this->_device, - $collectionData->folder + $collectionData->folder, + $collectionData->syncState->counter ); // fetch entries changed since last sync @@ -1031,7 +1032,7 @@ } //Retry in case of deadlock - $retries = 0; + $retryCounter = 0; while (True) { try { $transactionId = Syncroton_Registry::getTransactionManager()->startTransaction(Syncroton_Registry::getDatabase()); @@ -1040,7 +1041,13 @@ // store contentstates for new entries added to client foreach($newContentStates as $state) { - $this->_contentStateBackend->create($state); + try { + //This can happen if we rerun a previous sync-key + $state = $this->_contentStateBackend->getContentState($state->device_id, $state->folder_id, $state->contentid); + $this->_contentStateBackend->update($state); + } catch(Exception $zdse) { + $this->_contentStateBackend->create($state); + } } // remove contentstates for entries to be deleted on client @@ -1050,9 +1057,9 @@ Syncroton_Registry::getTransactionManager()->commitTransaction($transactionId); break; - } catch (Exception $zdse) { - $retries++; - if ($retries > 60) { + } catch (Syncroton_Exception_DeadlockDetected $zdse) { + $retryCounter++; + if ($retryCounter > 60) { if ($this->_logger instanceof Zend_Log) $this->_logger->warn(__METHOD__ . '::' . __LINE__ . ' exception while storing new synckey. Aborting after 5 retries.'); @@ -1076,6 +1083,22 @@ sleep(1); if ($this->_logger instanceof Zend_Log) $this->_logger->warn(__METHOD__ . '::' . __LINE__ . ' error during transaction, trying again.'); + } catch (Exception $zdse) { + if ($this->_logger instanceof Zend_Log) + $this->_logger->warn(__METHOD__ . '::' . __LINE__ . ' exception while storing new synckey.'); + // something went wrong + // maybe another parallel request added a new synckey + // we must remove data added from client + if (!empty($clientModifications'added')) { + foreach ($clientModifications'added' as $added) { + $this->_contentStateBackend->delete($added'contentState'); + $dataController->deleteEntry($collectionData->collectionId, $added'serverId', array()); + } + } + + Syncroton_Registry::getTransactionManager()->rollBack(); + + throw $zdse; } } }
View file
kolab-syncroton-2.4.0.tar.gz/lib/ext/Syncroton/Exception/DeadlockDetected.php
Added
@@ -0,0 +1,20 @@ +<?php +/** + * Syncroton + * + * @package Syncroton + * @subpackage Exception + * @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3 + * @copyright Copyright (c) 2013-2013 Metaways Infosystems GmbH (http://www.metaways.de) + * @author Lars Kneschke <l.kneschke@metaways.de> + */ + +/** + * exception for database deadlocks + * + * @package Syncroton + * @subpackage Exception + */ +class Syncroton_Exception_DeadlockDetected extends Syncroton_Exception +{ +}
View file
kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_backend_common.php
Changed
@@ -105,7 +105,12 @@ ); if ($err = $this->db->is_error($result)) { - throw new Exception('Failed to save instance of ' . $this->interface_name . ": " . $err); + //Deadlock detected + if ($this->db->error_info()0 == '40001') { + throw new Syncroton_Exception_DeadlockDetected('Failed to save instance of ' . $this->interface_name . ": " . $err); + } else { + throw new Exception('Failed to save instance of ' . $this->interface_name . ": " . $err); + } } return $object; @@ -152,7 +157,12 @@ $result = $this->db->query('DELETE FROM `' . $this->table_name .'` WHERE `id` = ?', array($id)); if ($err = $this->db->is_error($result)) { - throw new Exception('Failed to delete instance of ' . $this->interface_name . ": " . $err); + //Deadlock detected + if ($this->db->error_info()0 == '40001') { + throw new Syncroton_Exception_DeadlockDetected('Failed to delete instance of ' . $this->interface_name . ": " . $err); + } else { + throw new Exception('Failed to delete instance of ' . $this->interface_name . ": " . $err); + } } return (bool) $this->db->affected_rows($result); @@ -182,7 +192,12 @@ $result = $this->db->query('UPDATE `' . $this->table_name . '` SET ' . implode(', ', $set) . ' WHERE `id` = ' . $this->db->quote($object->id), array_values($data)); if ($err = $this->db->is_error($result)) { - throw new Exception('Failed to update instance of ' . $this->interface_name . ": " . $err); + //Deadlock detected + if ($this->db->error_info()0 == '40001') { + throw new Syncroton_Exception_DeadlockDetected('Failed to update instance of ' . $this->interface_name . ": " . $err); + } else { + throw new Exception('Failed to update instance of ' . $this->interface_name . ": " . $err); + } } return $object;
View file
kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_backend_content.php
Changed
@@ -84,7 +84,7 @@ * @param Syncroton_Model_IFolder|string $_folderId * @return array */ - public function getFolderState($_deviceId, $_folderId) + public function getFolderState($_deviceId, $_folderId, $syncKey = null) { $deviceId = $_deviceId instanceof Syncroton_Model_IDevice ? $_deviceId->id : $_deviceId; $folderId = $_folderId instanceof Syncroton_Model_IFolder ? $_folderId->id : $_folderId; @@ -98,6 +98,9 @@ $where = $this->db->quote_identifier('device_id') . ' = ' . $this->db->quote($deviceId); $where = $this->db->quote_identifier('folder_id') . ' = ' . $this->db->quote($folderId); + if ($syncKey) { + $where = $this->db->quote_identifier('creation_synckey') . ' < ' . $this->db->quote($syncKey + 1); + } $where = $this->db->quote_identifier('is_deleted') . ' = 0'; $select = $this->db->query("SELECT `contentid` FROM `{$this->table_name}` WHERE " . implode(' AND ', $where));
View file
kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_backend_state.php
Changed
@@ -192,7 +192,8 @@ $result = $this->db->query("DELETE FROM `syncroton_content` WHERE " . implode(' AND ', $where)); if ($this->db->is_error($result)) { $retryCounter++; - if ($retryCounter > 60) { + // Retry on deadlock + if ($this->db->error_info()0 != '40001' || $retryCounter > 60) { throw new Exception('Failed to delete entries in sync_key check'); } } else {
View file
kolab-syncroton-2.4.0.tar.gz/lib/kolab_sync_data.php
Changed
@@ -903,7 +903,7 @@ */ public function getCountOfChanges(Syncroton_Backend_IContent $contentBackend, Syncroton_Model_IFolder $folder, Syncroton_Model_ISyncState $syncState) { - $allClientEntries = $contentBackend->getFolderState($this->device, $folder); + $allClientEntries = $contentBackend->getFolderState($this->device, $folder, $syncState->counter); $allServerEntries = $this->getServerEntries($folder->serverId, $folder->lastfiltertype); $changedEntries = $this->getChangedEntriesCount($folder->serverId, $syncState->lastsync, null, $folder->lastfiltertype); $addedEntries = array_diff($allServerEntries, $allClientEntries); @@ -928,7 +928,7 @@ return true; } - $allClientEntries = $contentBackend->getFolderState($this->device, $folder); + $allClientEntries = $contentBackend->getFolderState($this->device, $folder, $syncState->counter); // @TODO: Consider looping over all folders here, not in getServerEntries() and // getChangedEntriesCount(). This way we could break the loop and not check all folders
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.