www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit bd7e1b222dd690904cf2d9260f8968d5a4e6016f
parent 3f6ecc00212a652465867cfb795d1e21dea8e91e
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu,  8 Feb 2018 03:06:06 -0500

Wait for any DB transactions to finish before starting sync

purgeDataObjects(), which runs at the beginning of the sync process,
uses transactions, and those can fail after the default wait timeout if
there's another active transaction. Instead, check explicitly for
another transaction and, if there is one, display a nice message and
wait for it to finish. This isn't foolproof, but it should reduce the
frequency of "operation timed out" sync errors. (Avoiding all long
transactions would be a better solution.)

Diffstat:
Mchrome/content/zotero/xpcom/sync/syncRunner.js | 13+++++++++++++
Mchrome/locale/en-US/zotero/zotero.properties | 2++
2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js @@ -139,6 +139,19 @@ Zotero.Sync.Runner_Module = function (options = {}) { this.updateIcons('animate'); + // purgeDataObjects() starts a transaction, so if there's an active one then show a + // nice message and wait until there's not. Another transaction could still start + // before purgeDataObjects() and result in a wait timeout, but this should reduce the + // frequency of that. + while (Zotero.DB.inTransaction()) { + this.setSyncStatus(Zotero.getString('sync.status.waiting')); + Zotero.debug("Transaction in progress -- waiting to sync"); + yield Zotero.DB.waitForTransaction('sync'); + _stopCheck(); + } + + this.setSyncStatus(Zotero.getString('sync.status.preparing')); + // Purge deleted objects so they don't cause sync errors (e.g., long tags) yield Zotero.purgeDataObjects(true); diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -952,6 +952,8 @@ sync.conflict.chooseThisVersion = Choose this version sync.status.notYetSynced = Not yet synced sync.status.lastSync = Last sync: +sync.status.waiting = Waiting for other operations to finish +sync.status.preparing = Preparing sync sync.status.loggingIn = Logging in to sync server sync.status.gettingUpdatedData = Getting updated data from sync server sync.status.processingUpdatedData = Processing updated data from sync server