From ffe15f154541b6f929c569caf07560d117ad5efa Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 11 Aug 2016 11:34:47 -0300 Subject: [feature] use transactions on sync We were using 1 transaction per doc, which is bad. Reference: http://stackoverflow.com/questions/1711631/improve-insert-per-second-performance-of-sqlite Code now uses 1 transaction for the whole sync. --- client/src/leap/soledad/client/sqlcipher.py | 3 +++ client/src/leap/soledad/client/sync.py | 1 + 2 files changed, 4 insertions(+) (limited to 'client/src') diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py index 3921c323..b198607d 100644 --- a/client/src/leap/soledad/client/sqlcipher.py +++ b/client/src/leap/soledad/client/sqlcipher.py @@ -458,6 +458,9 @@ class SQLCipherU1DBSync(SQLCipherDatabase): if DO_STATS: self.sync_phase = None + def commit(self): + self._db_handle.commit() + @property def _replica_uid(self): return str(self.__replica_uid) diff --git a/client/src/leap/soledad/client/sync.py b/client/src/leap/soledad/client/sync.py index 7ed5f693..8303f65d 100644 --- a/client/src/leap/soledad/client/sync.py +++ b/client/src/leap/soledad/client/sync.py @@ -176,6 +176,7 @@ class SoledadSynchronizer(Synchronizer): defer_decryption=defer_decryption) logger.debug("target gen after sync: %d" % new_gen) logger.debug("target trans_id after sync: %s" % new_trans_id) + self.source.commit() # sync worked, commit info = { "target_replica_uid": self.target_replica_uid, "new_gen": new_gen, -- cgit v1.2.3