Author: shawkins
Date: 2011-08-12 10:35:37 -0400 (Fri, 12 Aug 2011)
New Revision: 3379
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
Log:
TEIID-1701 ensuring that the txn is properly associated
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2011-08-11
20:12:07 UTC (rev 3378)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2011-08-12
14:35:37 UTC (rev 3379)
@@ -140,6 +140,7 @@
private boolean requiresTransaction = true;
private TransactionContext blockContext;
+ private boolean inTxn;
/**
* Resources cannot be held open across the txn boundary. This list is a hack at
ensuring the resources are closed.
*/
@@ -218,7 +219,7 @@
beginBatch = 1;
batchRows = null;
lastBatch = false;
-
+ inTxn = false;
//reset program stack
programs.clear();
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "ProcedurePlan
reset"); //$NON-NLS-1$
@@ -276,13 +277,15 @@
@Override
public TupleBatch nextBatch() throws BlockedException,
TeiidComponentException, TeiidProcessingException {
- if (blockContext != null) {
+ if (blockContext != null && !this.inTxn) {
this.getContext().getTransactionServer().resume(blockContext);
+ this.inTxn = true;
}
try {
return nextBatchDirect();
} finally {
if (blockContext != null) {
+ this.inTxn = false;
this.getContext().getTransactionServer().suspend(blockContext);
}
}
@@ -602,14 +605,17 @@
TransactionService ts = this.getContext().getTransactionServer();
TransactionContext tc = this.blockContext;
this.blockContext = null;
- for (WeakReference<DataTierTupleSource> ref : txnTupleSources) {
- DataTierTupleSource dtts = ref.get();
- if (dtts != null) {
- dtts.fullyCloseSource();
- }
- }
- this.txnTupleSources.clear();
try {
+ if (!inTxn) {
+ this.getContext().getTransactionServer().resume(tc);
+ }
+ for (WeakReference<DataTierTupleSource> ref : txnTupleSources) {
+ DataTierTupleSource dtts = ref.get();
+ if (dtts != null) {
+ dtts.fullyCloseSource();
+ }
+ }
+ this.txnTupleSources.clear();
if (success) {
ts.commit(tc);
} else {
@@ -636,6 +642,7 @@
if (tc != null && tc.getTransactionType() == Scope.NONE) {
//start a transaction
this.getContext().getTransactionServer().begin(tc);
+ this.inTxn = true;
this.blockContext = tc;
this.peek().setStartedTxn(true);
}
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2011-08-11
20:12:07 UTC (rev 3378)
+++
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2011-08-12
14:35:37 UTC (rev 3379)
@@ -2523,6 +2523,7 @@
}
Mockito.verify(ts).begin(tc);
+ Mockito.verify(ts).resume(tc);
Mockito.verify(ts, Mockito.times(0)).commit(tc);
Mockito.verify(ts).rollback(tc);
}