Skip to content

Commit

Permalink
Revert "TEIID-3781 ensuring cancellation is more immediate"
Browse files Browse the repository at this point in the history
This reverts commit e2a864c.
  • Loading branch information
shawkins committed Oct 21, 2015
1 parent e2a864c commit 3494c98
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 45 deletions.
Expand Up @@ -503,7 +503,7 @@ private boolean cancelRequest(RequestID requestID) throws TeiidComponentExceptio
if (markCancelled) {
logMMCommand(workItem, Event.CANCEL, null, null);
} else {
LogManager.logDetail(LogConstants.CTX_DQP, QueryPlugin.Util.getString("DQPCore.failed_to_cancel", requestID)); //$NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_DQP, QueryPlugin.Util.getString("DQPCore.failed_to_cancel")); //$NON-NLS-1$
}
return markCancelled;
}
Expand Down
Expand Up @@ -270,7 +270,6 @@ public List<Exception> getAndClearWarnings() {
*/
public void requestCanceled() {
this.requestCanceled = true;
this.context.requestCancelled();
}

public BatchCollector createBatchCollector() throws TeiidComponentException {
Expand Down
Expand Up @@ -41,7 +41,6 @@
import org.teiid.core.util.Assertion;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.processor.BatchCollector.BatchProducer;
import org.teiid.query.processor.ProcessorDataManager;
Expand Down Expand Up @@ -268,25 +267,24 @@ public void open()
* @since 4.2
*/
public final TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException {
CommandContext context = this.getContext();
if (context != null && context.isCancelled()) {
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30160, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30160, getContext().getRequestId()));
}
boolean recordStats = context != null && context.getCollectNodeStatistics();
boolean recordStats = this.getProcessingState().context != null && this.getProcessingState().context.getCollectNodeStatistics();

try {
while (true) {
//start timer for this batch
if(recordStats) {
if(recordStats && this.getProcessingState().context.getCollectNodeStatistics()) {
this.getProcessingState().nodeStatistics.startBatchTimer();
}
TupleBatch batch = nextBatchDirect();
if (recordStats) {
// stop timer for this batch (normal)
this.getProcessingState().nodeStatistics.stopBatchTimer();
this.getProcessingState().nodeStatistics.collectCumulativeNodeStats(batch, RelationalNodeStatistics.BATCHCOMPLETE_STOP);
if (batch.getTerminationFlag()) {
this.getProcessingState().nodeStatistics.collectNodeStats(this.getChildren());
//this.nodeStatistics.dumpProperties(this.getClassName());
if(this.getProcessingState().context.getCollectNodeStatistics()) {
// stop timer for this batch (normal)
this.getProcessingState().nodeStatistics.stopBatchTimer();
this.getProcessingState().nodeStatistics.collectCumulativeNodeStats(batch, RelationalNodeStatistics.BATCHCOMPLETE_STOP);
if (batch.getTerminationFlag()) {
this.getProcessingState().nodeStatistics.collectNodeStats(this.getChildren());
//this.nodeStatistics.dumpProperties(this.getClassName());
}
}
this.recordBatch(batch);
recordStats = false;
Expand All @@ -302,15 +300,15 @@ public final TupleBatch nextBatch() throws BlockedException, TeiidComponentExce
}
}
} catch (BlockedException e) {
if(recordStats) {
if(recordStats && this.getProcessingState().context.getCollectNodeStatistics()) {
// stop timer for this batch (BlockedException)
this.getProcessingState().nodeStatistics.stopBatchTimer();
this.getProcessingState().nodeStatistics.collectCumulativeNodeStats(null, RelationalNodeStatistics.BLOCKEDEXCEPTION_STOP);
recordStats = false;
}
throw e;
} finally {
if(recordStats) {
if(recordStats && this.getProcessingState().context.getCollectNodeStatistics()) {
this.getProcessingState().nodeStatistics.stopBatchTimer();
}
}
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/resources/org/teiid/query/i18n.properties
Expand Up @@ -1001,7 +1001,7 @@ DQPCore.Clearing_prepared_plan_cache_for_vdb=Clearing prepared plan cache for vd
DQPCore.clearing_resultset_cache=Clearing the resultset cache for vdb {0}.{1}
TEIID30495=The request {0} has been closed.
DQPCore.The_atomic_request_has_been_cancelled=The atomic request {0} has been canceled.
DQPCore.failed_to_cancel=Failed to Cancel request {0}
DQPCore.failed_to_cancel=Failed to Cancel request, as request already finished processing
TEIID30006=The maxActivePlan {0} setting should never be greater than the max processing threads {1}.

TEIID30028=Failed to properly rollback autowrap transaction properly
Expand Down
27 changes: 0 additions & 27 deletions runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
Expand Up @@ -1459,32 +1459,5 @@ private void extractRowCount(String query, Statement s, int count)
assertEquals(rs.getInt(3), rs.getInt(4));
}
}

@Test(expected=TeiidSQLException.class) public void testCancelSystemQuery() throws Exception {
EmbeddedConfiguration ec = new EmbeddedConfiguration();
es.start(ec);
ModelMetaData mmd = new ModelMetaData();
mmd.setName("x");
mmd.setModelType(Type.VIRTUAL);
mmd.addSourceMetadata("ddl", "create view v as select 1;");
es.deployVDB("x", mmd);
Connection c = es.getDriver().connect("jdbc:teiid:x", null);
final Statement s = c.createStatement();
Thread t = new Thread() {
@Override
public void run() {
try {
Thread.sleep(1000);
s.cancel();
} catch (InterruptedException e) {
} catch (SQLException e) {
}
}
};
t.start();
ResultSet rs = s.executeQuery("select count(*) from columns c, columns c1, columns c2, columns c3, columns c4");
rs.next();
fail();
}

}

0 comments on commit 3494c98

Please sign in to comment.