Commit 60746157 authored by 's avatar

Merged fix for non-subtransaction supporting jars from 2.3 branch

parent aeab8c93
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
############################################################################## ##############################################################################
"""Transaction management """Transaction management
$Id: Transaction.py,v 1.26 2001/02/15 20:01:12 jim Exp $""" $Id: Transaction.py,v 1.27 2001/02/26 20:33:50 brian Exp $"""
__version__='$Revision: 1.26 $'[11:-2] __version__='$Revision: 1.27 $'[11:-2]
import time, sys, struct, POSException import time, sys, struct, POSException
from struct import pack from struct import pack
...@@ -103,8 +103,14 @@ class Transaction: ...@@ -103,8 +103,14 @@ class Transaction:
_connections=None _connections=None
_extension=None _extension=None
_sub=None # This is a subtrasaction flag _sub=None # This is a subtrasaction flag
_sub_no_partial_abort=None
# The _non_st_objects variable is either None or a list
# of jars that do not support subtransactions. This is used to
# manage non-subtransaction-supporting jars during subtransaction
# commits and aborts to ensure that they are correctly committed
# or aborted in the "outside" transaction.
_non_st_objects=None
def __init__(self, id=None): def __init__(self, id=None):
self._id=id self._id=id
self._objects=[] self._objects=[]
...@@ -138,7 +144,7 @@ class Transaction: ...@@ -138,7 +144,7 @@ class Transaction:
entered two-phase commit yet, so no tpc_ messages are sent. entered two-phase commit yet, so no tpc_ messages are sent.
''' '''
if subtransaction and self._sub_no_partial_abort: if subtransaction and (self._non_st_objects is not None):
raise POSException.TransactionError, ( raise POSException.TransactionError, (
"""Attempted to abort a sub-transaction, but a participating """Attempted to abort a sub-transaction, but a participating
data manager doesn't support partial abort. data manager doesn't support partial abort.
...@@ -149,12 +155,21 @@ class Transaction: ...@@ -149,12 +155,21 @@ class Transaction:
subjars=() subjars=()
if not subtransaction: if not subtransaction:
# Must add in any non-subtransaction supporting objects that
# may have been stowed away from previous subtransaction
# commits.
if self._non_st_objects is not None:
append=self._objects.append
for object in self._non_st_objects:
append(object)
self._non_st_objects = None
if subj is not None: if subj is not None:
# Abort of top-level transaction after commiting # Abort of top-level transaction after commiting
# subtransactions. # subtransactions.
subjars=subj.values() subjars=subj.values()
self._sub=None self._sub=None
self._sub_no_partial_abort=None
try: try:
# Abort the objects # Abort the objects
...@@ -199,6 +214,7 @@ class Transaction: ...@@ -199,6 +214,7 @@ class Transaction:
jarsv = None jarsv = None
subj=self._sub subj=self._sub
subjars=() subjars=()
if subtransaction: if subtransaction:
if subj is None: self._sub=subj={} if subj is None: self._sub=subj={}
else: else:
...@@ -209,7 +225,15 @@ class Transaction: ...@@ -209,7 +225,15 @@ class Transaction:
objects=[] objects=[]
subjars=subj.values() subjars=subj.values()
self._sub=None self._sub=None
self._sub_no_partial_abort=None
# If not a subtransaction, then we need to add any non-
# subtransaction-supporting objects that may have been
# stowed away during subtransaction commits to _objects.
if (subtransaction is None) and (self._non_st_objects is not None):
append=objects.append
for object in self._non_st_objects:
append(object)
self._non_st_objects = None
t=v=tb=None t=v=tb=None
...@@ -255,12 +279,22 @@ class Transaction: ...@@ -255,12 +279,22 @@ class Transaction:
if not jars.has_key(i): if not jars.has_key(i):
jars[i]=j jars[i]=j
if subtransaction: if subtransaction:
# If a jar does not support subtransactions,
# we need to save it away to be committed in
# the outer transaction.
try: j.tpc_begin(self, subtransaction) try: j.tpc_begin(self, subtransaction)
except TypeError: except TypeError:
j.tpc_begin(self) j.tpc_begin(self)
self._sub_no_partial_abort=1
else: if hasattr(j, 'commit_sub'):
subj[i]=j subj[i]=j
else:
if self._non_st_objects is None:
self._non_st_objects = []
self._non_st_objects.append(o)
continue
else: else:
j.tpc_begin(self) j.tpc_begin(self)
j.commit(o,self) j.commit(o,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