Author: shawkins
Date: 2011-06-23 14:19:58 -0400 (Thu, 23 Jun 2011)
New Revision: 3265
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
Log:
TEIID-1654 ensuring that missing cache entries are not restored
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2011-06-23
17:31:30 UTC (rev 3264)
+++
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2011-06-23
18:19:58 UTC (rev 3265)
@@ -125,18 +125,19 @@
@Override
public synchronized boolean restore(Cache cache, BufferManager bufferManager) {
- try {
- if (this.results == null) {
- if (this.hasLobs) {
- return false;
- }
+ if (this.results == null) {
+ if (this.hasLobs) {
+ return false; //the lob store is local only and not distributed
+ }
+ TupleBuffer buffer = null;
+ try {
List<ElementSymbol> schema = new ArrayList<ElementSymbol>(types.length);
for (String type : types) {
ElementSymbol es = new ElementSymbol("x"); //$NON-NLS-1$
es.setType(DataTypeManager.getDataTypeClass(type));
schema.add(es);
}
- TupleBuffer buffer = bufferManager.createTupleBuffer(schema, "cached",
TupleSourceType.FINAL); //$NON-NLS-1$
+ buffer = bufferManager.createTupleBuffer(schema, "cached",
TupleSourceType.FINAL); //$NON-NLS-1$
buffer.setBatchSize(this.batchSize);
if (this.hint != null) {
buffer.setPrefersMemory(this.hint.getPrefersMemory());
@@ -144,20 +145,26 @@
for (int row = 1; row <= this.rowCount; row+=this.batchSize) {
TupleBatch batch = (TupleBatch)cache.get(uuid+","+row); //$NON-NLS-1$
- if (batch != null) {
- buffer.addTupleBatch(batch, true);
- }
+ if (batch == null) {
+ LogManager.logInfo(LogConstants.CTX_DQP,
QueryPlugin.Util.getString("not_found_cache")); //$NON-NLS-1$
+ buffer.remove();
+ return false;
+ }
+ buffer.addTupleBatch(batch, true);
}
this.results = buffer;
bufferManager.addTupleBuffer(this.results);
this.results.close();
+ this.accessInfo.restore();
+ } catch (TeiidException e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e,
QueryPlugin.Util.getString("unexpected_exception_restoring_results"));
//$NON-NLS-1$
+ if (buffer != null) {
+ buffer.remove();
+ }
+ return false;
}
- this.accessInfo.restore();
- return true;
- } catch (TeiidException e) {
- LogManager.logDetail(LogConstants.CTX_DQP, e,
QueryPlugin.Util.getString("not_found_cache")); //$NON-NLS-1$
}
- return false;
+ return true;
}
@Override
Modified: branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties 2011-06-23
17:31:30 UTC (rev 3264)
+++ branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties 2011-06-23
18:19:58 UTC (rev 3265)
@@ -901,7 +901,8 @@
datasource_not_found=Data Source {0} not accessible.
RequestWorkItem.cache_nondeterministic=Caching command "{0}" at a session
level, but less deterministic functions were evaluated.
-not_found_cache=Failed to restore results
+not_found_cache=Failed to restore results, since batch entries were missing. The entry
will be re-populated.
+unexpected_exception_restoring_results=Failed to restore results. The entry will be
re-populated.
failed_to_cache=Failed to store the result set contents to disk.
failed_to_unwrap_connection=Failed to unwrap the source connection.
connection_factory_not_found=Failed to find the Connection Factory with JNDI name {0}.
Please check the name or deploy the Connection Factory with specified name.
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2011-06-23
17:31:30 UTC (rev 3264)
+++
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2011-06-23
18:19:58 UTC (rev 3265)
@@ -92,7 +92,7 @@
RealMetadataFactory.buildWorkContext(RealMetadataFactory.exampleBQT());
- cachedResults.restore(cache, bm);
+ assertTrue(cachedResults.restore(cache, bm));
// since restored, simulate a async cache flush
cache.clear();
@@ -106,5 +106,10 @@
assertArrayEquals(tb.getBatch(1).getAllTuples(), cachedTb.getBatch(1).getAllTuples());
assertArrayEquals(tb.getBatch(9).getAllTuples(), cachedTb.getBatch(9).getAllTuples());
assertTrue(ts - cachedResults.getAccessInfo().getCreationTime() <= 5000);
+
+ //ensure that an incomplete load fails
+ cache.remove(results.getId()+","+1); //$NON-NLS-1$
+ cachedResults = UnitTestUtil.helpSerialize(results);
+ assertFalse(cachedResults.restore(cache, bm));
}
}
Show replies by date