Merge lp:~jfb-tempo-consulting/unifield-server/us-1341 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4485
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/us-1341
Merge into: lp:unifield-server
Diff against target: 136 lines (+66/-26)
3 files modified
bin/addons/msf_profile/i18n/fr_MF.po (+14/-0)
bin/addons/sync_client/orm.py (+4/-8)
bin/addons/sync_client/sync_client.py (+48/-18)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/us-1341
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+329439@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeff Allen (jr.allen) wrote :

UF 6.0 unfortunately needs to tolerate the time when pg 8.4 and pg 9.6 is mixed in the fleet. Until now we didn't notice any use of Postgres where that would make a difference, but I'm afraid this won't work on Pg 8.4.

Your thoughts?

Revision history for this message
jftempo (jfb-tempo-consulting) wrote :

To my knowledge (but I didn't test this code on pg8.4):
   - pg8.4 ISOLATION_LEVEL_REPEATABLE_READ == pg8.4 ISOLATION_LEVEL_SERIALIZABLE
   - pg8.4 ISOLATION_LEVEL_SERIALIZABLE == pg9.6 ISOLATION_LEVEL_REPEATABLE_READ

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
--- bin/addons/msf_profile/i18n/fr_MF.po 2017-08-18 15:27:28 +0000
+++ bin/addons/msf_profile/i18n/fr_MF.po 2017-08-29 09:52:36 +0000
@@ -98950,3 +98950,17 @@
98950#: field:sync.version.instance.monitor,instance_state:098950#: field:sync.version.instance.monitor,instance_state:0
98951msgid "Instance State"98951msgid "Instance State"
98952msgstr "État de l'instance"98952msgstr "État de l'instance"
98953
98954#. module: sync_client
98955#: code:addons/sync_client/sync_client.py:670
98956#, python-format
98957msgid "Unable to generate updates after %d tries"
98958msgstr "Impossible de générer les data après %d tentatives"
98959
98960#. module: sync_client
98961#: code:addons/sync_client/sync_client.py:677
98962#, python-format
98963msgid "Unable to generate updates, retrying %d/%d"
98964msgstr "Impossible de générer les data, nouvel essai %d/%d"
98965
98966
9895398967
=== modified file 'bin/addons/sync_client/orm.py'
--- bin/addons/sync_client/orm.py 2017-02-20 09:08:28 +0000
+++ bin/addons/sync_client/orm.py 2017-08-29 09:52:36 +0000
@@ -122,13 +122,9 @@
122 WHERE module = 'sd' AND122 WHERE module = 'sd' AND
123 model = %s AND123 model = %s AND
124 """+add_sql+"""124 """+add_sql+"""
125 ("""+field+""" < last_modification OR """+field+""" IS NULL) AND125 ("""+field+""" < last_modification OR """+field+""" IS NULL)
126 (create_date is NULL or create_date <= NOW())""",126 """,
127 sql_params)127 sql_params)
128 # NOW() is the sql transaction begin date
129 # can't use (sync_date IS NULL or last_modification <= NOW()) bc UTP-1201 use case failed
130 # can't use (last_modification <= NOW()) bc a record created before the sync but updated during the sync will not be sent
131 # and if this record is used in a m2o it will be set to false
132 result = [row[0] for row in cr.fetchall()]128 result = [row[0] for row in cr.fetchall()]
133 else:129 else:
134 touched_fields = set(touched_fields)130 touched_fields = set(touched_fields)
@@ -138,8 +134,8 @@
138 WHERE module = 'sd' AND134 WHERE module = 'sd' AND
139 model = %s AND135 model = %s AND
140 """+add_sql+"""136 """+add_sql+"""
141 ("""+field+""" < last_modification OR """+field+""" IS NULL) AND137 ("""+field+""" < last_modification OR """+field+""" IS NULL)
142 (create_date is NULL or create_date <= NOW())""",138 """,
143 sql_params)139 sql_params)
144 result = [row[0] for row in cr.fetchall()140 result = [row[0] for row in cr.fetchall()
145 if row[1] is None \141 if row[1] is None \
146142
=== modified file 'bin/addons/sync_client/sync_client.py'
--- bin/addons/sync_client/sync_client.py 2017-08-18 14:46:12 +0000
+++ bin/addons/sync_client/sync_client.py 2017-08-29 09:52:36 +0000
@@ -32,6 +32,7 @@
32import math32import math
33import hashlib33import hashlib
34from psycopg2 import OperationalError34from psycopg2 import OperationalError
35from psycopg2.extensions import ISOLATION_LEVEL_REPEATABLE_READ, TransactionRollbackError
3536
36import logging37import logging
37from sync_common import get_md5, check_md538from sync_common import get_md5, check_md5
@@ -637,24 +638,53 @@
637 return True638 return True
638639
639 @sync_subprocess('data_push_create')640 @sync_subprocess('data_push_create')
640 def create_update(self, cr, uid, context=None):641 def create_update(self, oldcr, uid, context=None):
641 context = context or {}642 cr = pooler.get_db(oldcr.dbname).cursor()
642 updates = self.pool.get(context.get('update_to_send_model', 'sync.client.update_to_send'))643 cr._cnx.set_isolation_level(ISOLATION_LEVEL_REPEATABLE_READ)
643644 nb_tries = 1
644 def prepare_update(session):645 MAX_TRIES = 10
645 updates_count = 0646 while True:
646 for rule_id in self.pool.get('sync.client.rule').search(cr, uid, [('type', '!=', 'USB')], context=context):647 try:
647 updates_count += sum(updates.create_update(648 context = context or {}
648 cr, uid, rule_id, session, context=context))649 logger = context.get('logger')
649 return updates_count650 updates = self.pool.get(context.get('update_to_send_model', 'sync.client.update_to_send'))
650651
651 entity = self.get_entity(cr, uid, context)652 def prepare_update(session):
652 session = str(uuid.uuid1())653 updates_count = 0
653 updates_count = prepare_update(session)654 for rule_id in self.pool.get('sync.client.rule').search(cr, uid, [('type', '!=', 'USB')], context=context):
654 if updates_count > 0:655 updates_count += sum(updates.create_update(
655 self.write(cr, uid, [entity.id], {'session_id' : session})656 cr, uid, rule_id, session, context=context))
656 return updates_count657 return updates_count
657 #state init => update_send658
659 entity = self.get_entity(cr, uid, context)
660 session = str(uuid.uuid1())
661 updates_count = prepare_update(session)
662 if updates_count > 0:
663 self.write(cr, uid, [entity.id], {'session_id' : session})
664 cr.commit()
665 cr.close(True)
666 return updates_count
667 except TransactionRollbackError:
668 cr.rollback()
669 if nb_tries == MAX_TRIES:
670 msg = _("Unable to generate updates after %d tries") % MAX_TRIES
671 if logger:
672 logger.append(msg)
673 logger.write()
674 self._logger.info(msg)
675 cr.close(True)
676 raise
677 msg = _("Unable to generate updates, retrying %d/%d") % (nb_tries, MAX_TRIES)
678 if logger:
679 logger.append(msg)
680 logger.write()
681 self._logger.info(msg)
682 nb_tries += 1
683 except:
684 cr.rollback()
685 cr.close(True)
686 raise
687
658688
659 @sync_subprocess('data_push_send')689 @sync_subprocess('data_push_send')
660 def send_update(self, cr, uid, context=None):690 def send_update(self, cr, uid, context=None):

Subscribers

People subscribed via source and target branches