Commit c2ed78f3 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Fix a serious mistake which led to committing the same object twice. Also,...

Fix a serious mistake which led to committing the same object twice. Also, remove an unnecessary piece of code.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16719 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c1ffe82c
...@@ -83,13 +83,9 @@ try: ...@@ -83,13 +83,9 @@ try:
# Do prepare until number of jars is stable - this could # Do prepare until number of jars is stable - this could
# create infinite loop # create infinite loop
jars_len = -1 jars_len = -1
objects_len = len(self._objects)
while len(jars) != jars_len: while len(jars) != jars_len:
jars_len = len(jars) jars_len = len(jars)
self._commit_prepare(jars, subjars, subtransaction) self._commit_prepare(jars, subjars, subtransaction)
if len(self._objects) != objects_len:
objects.extend(self._objects[objects_len:])
objects_len = len(self._objects)
jars = self._get_jars(objects, subtransaction) jars = self._get_jars(objects, subtransaction)
# If not subtransaction, then jars will be modified. # If not subtransaction, then jars will be modified.
self._commit_begin(jars, subjars, subtransaction) self._commit_begin(jars, subjars, subtransaction)
...@@ -146,24 +142,17 @@ try: ...@@ -146,24 +142,17 @@ try:
# support subtransactions. # support subtransactions.
tpc_prepare(self) tpc_prepare(self)
else: else:
# Merge in all the jars used by one of the subtransactions. # Perform tpc_prepare for both jars and subjars.
# Note that it must not be executed for the same jar
# When the top-level subtransaction commits, the tm must # more than once. Also, this should not merge the jars
# call commit_sub() for each jar involved in one of the # in place, as _commit_begin will do that.
# subtransactions. The commit_sub() method should call for jar in subjars:
# tpc_begin() on the storage object. tpc_prepare = getattr(jar, 'tpc_prepare', None)
if tpc_prepare is not None:
# It must also call tpc_begin() on jars that were used in tpc_prepare(self)
# a subtransaction but don't support subtransactions.
# These operations must be performed on the jars in order.
# Modify jars inplace to include the subjars, too.
jars += subjars
jars.sort(jar_cmp)
# assume that subjars is small, so that it's cheaper to test
# whether jar in subjars than to make a dict and do has_key.
for jar in jars: for jar in jars:
if jar not in subjars:
tpc_prepare = getattr(jar, 'tpc_prepare', None) tpc_prepare = getattr(jar, 'tpc_prepare', None)
if tpc_prepare is not None: if tpc_prepare is not None:
tpc_prepare(self) tpc_prepare(self)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment