# HG changeset patch # User Sylvain Thénault # Date 1455616320 -3600 # Node ID e717da3dc1646b23dae8f1a4db7e786564cbdca1 # Parent 5fdbf6f2db881c3ee89f7d80d39cbd163acbd8dc c-c source-sync now actually force synchronization as advertized by its help message. This was because "force" argument wasn't considered by acquire_synchronization_lock(). diff -r 5fdbf6f2db88 -r e717da3dc164 cubicweb/server/sources/datafeed.py --- a/cubicweb/server/sources/datafeed.py Fri Jan 29 17:22:25 2016 +0100 +++ b/cubicweb/server/sources/datafeed.py Tue Feb 16 10:52:00 2016 +0100 @@ -171,14 +171,18 @@ {'x': self.eid, 'date': self.latest_retrieval}) cnx.commit() - def acquire_synchronization_lock(self, cnx): + def acquire_synchronization_lock(self, cnx, force=False): # XXX race condition until WHERE of SET queries is executed using # 'SELECT FOR UPDATE' now = datetime.now(tz=utc) + if force: + maxdt = now + else: + maxdt = now - self.max_lock_lifetime if not cnx.execute( - 'SET X in_synchronization %(now)s WHERE X eid %(x)s, ' - 'X in_synchronization NULL OR X in_synchronization < %(maxdt)s', - {'x': self.eid, 'now': now, 'maxdt': now - self.max_lock_lifetime}): + 'SET X in_synchronization %(now)s WHERE X eid %(x)s, ' + 'X in_synchronization NULL OR X in_synchronization < %(maxdt)s', + {'x': self.eid, 'now': now, 'maxdt': maxdt}): self.error('concurrent synchronization detected, skip pull') cnx.commit() return False @@ -198,7 +202,7 @@ """ if not force and self.fresh(): return {} - if not self.acquire_synchronization_lock(cnx): + if not self.acquire_synchronization_lock(cnx, force): return {} try: return self._pull_data(cnx, force, raise_on_error)