]
Van Halbert updated TEIID-4167:
-------------------------------
Fix Version/s: 9.x
Infinispan translator specific clause in sql query causes
NullPointerException
------------------------------------------------------------------------------
Key: TEIID-4167
URL:
https://issues.jboss.org/browse/TEIID-4167
Project: Teiid
Issue Type: Bug
Components: Misc. Connectors
Affects Versions: 8.12.5
Reporter: Jan Stastny
Assignee: Van Halbert
Priority: Optional
Fix For: 9.x, 8.12.5
When using DSL enabled infinispan-cache translator, NullPointerException occurs when
executing a query with LIMIT clause:
{code:sql}
SELECT * FROM CustomerReport LIMIT 100;
{code}
or with non-trivial WHERE clause (doesn't matter whether such row exists or not):
{code:sql}
SELECT * FROM CustomerReport WHERE customerId=1;
{code}
{code:plain}
09:50:18,253 DEBUG [org.teiid.PROCESSOR] (Worker1_QueryProcessorQueue1) Running task for
parent thread Worker0_QueryProcessorQueue0
09:50:18,255 DEBUG [org.teiid.CONNECTOR] (Worker1_QueryProcessorQueue1)
ZzVxT/W8iN+B.0.0.0 Processing NEW request: SELECT jdgSource.CustomerReport.totalAmount
FROM jdgSource.CustomerReport LIMIT 100
09:50:18,500 INFO [org.teiid.CONNECTOR] (Worker1_QueryProcessorQueue1) === Using
DefaultCacheManager (loaded by configuration) ===
09:50:18,505 INFO [org.infinispan.factories.GlobalComponentRegistry]
(Worker1_QueryProcessorQueue1) ISPN000128: Infinispan version: Infinispan
'Infinium' 6.4.0.Final-redhat-4
09:50:18,833 DEBUG [org.teiid.CONNECTOR] (Worker1_QueryProcessorQueue1) Infinispan-Cache
Connection has been created.
09:50:18,841 DEBUG [org.teiid.CONNECTOR] (Worker1_QueryProcessorQueue1)
ZzVxT/W8iN+B.0.0.0 Obtained execution
09:50:18,889 ERROR [org.teiid.CONNECTOR] (Worker1_QueryProcessorQueue1) Connector worker
process failed for atomic-request=ZzVxT/W8iN+B.0.0.0: java.lang.NullPointerException
at org.infinispan.query.dsl.embedded.impl.QueryEngine.parse(QueryEngine.java:623)
[infinispan-query-6.4.0.Final-redhat-4.jar:6.4.0.Final-redhat-4]
at org.infinispan.query.dsl.embedded.impl.QueryEngine.buildQuery(QueryEngine.java:93)
[infinispan-query-6.4.0.Final-redhat-4.jar:6.4.0.Final-redhat-4]
at
org.infinispan.query.dsl.embedded.impl.DelegatingQuery.createQuery(DelegatingQuery.java:38)
[infinispan-query-6.4.0.Final-redhat-4.jar:6.4.0.Final-redhat-4]
at org.infinispan.query.dsl.embedded.impl.DelegatingQuery.list(DelegatingQuery.java:45)
[infinispan-query-6.4.0.Final-redhat-4.jar:6.4.0.Final-redhat-4]
at org.teiid.resource.adapter.infinispan.DSLSearch.performSearch(DSLSearch.java:176)
at org.teiid.resource.adapter.infinispan.DSLSearch.performSearch(DSLSearch.java:130)
at org.teiid.translator.object.ObjectExecution.execute(ObjectExecution.java:259)
[translator-object-8.12.5.redhat-3.jar:8.12.5]
at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:359)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[rt.jar:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_51]
at org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:211)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at com.sun.proxy.$Proxy124.execute(Unknown Source)
at
org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:306)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at
org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:112)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at
org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:108)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_51]
at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:65)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:276)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at
org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at
org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:210)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
09:50:18,895 DEBUG [org.teiid.PROCESSOR] (Worker0_QueryProcessorQueue2) Request Thread
ZzVxT/W8iN+B.0 with state PROCESSING
09:50:18,896 ERROR [org.teiid.PROCESSOR] (Worker0_QueryProcessorQueue2) TEIID30019
Unexpected exception for request ZzVxT/W8iN+B.0: java.lang.NullPointerException
at org.infinispan.query.dsl.embedded.impl.QueryEngine.parse(QueryEngine.java:623)
at org.infinispan.query.dsl.embedded.impl.QueryEngine.buildQuery(QueryEngine.java:93)
at
org.infinispan.query.dsl.embedded.impl.DelegatingQuery.createQuery(DelegatingQuery.java:38)
at org.infinispan.query.dsl.embedded.impl.DelegatingQuery.list(DelegatingQuery.java:45)
at org.teiid.resource.adapter.infinispan.DSLSearch.performSearch(DSLSearch.java:176)
at org.teiid.resource.adapter.infinispan.DSLSearch.performSearch(DSLSearch.java:130)
at org.teiid.translator.object.ObjectExecution.execute(ObjectExecution.java:259)
at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:359)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[rt.jar:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_51]
at org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:211)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at com.sun.proxy.$Proxy124.execute(Unknown Source)
at
org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:306)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at
org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:112)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at
org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:108)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_51]
at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:65)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:276)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at
org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at
org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:210)
[teiid-engine-8.12.5.redhat-3.jar:8.12.5.redhat-3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
09:50:18,899 DEBUG [org.teiid.PROCESSOR] (Worker0_QueryProcessorQueue2) QueryProcessor:
closing processor
09:50:18,899 DEBUG [org.teiid.CONNECTOR] (Worker0_QueryProcessorQueue2)
ZzVxT/W8iN+B.0.0.0 Remove State
09:50:18,900 DEBUG [org.teiid.CONNECTOR] (Worker0_QueryProcessorQueue2)
ZzVxT/W8iN+B.0.0.0 Processing Close : SELECT jdgSource.CustomerReport.totalAmount FROM
jdgSource.CustomerReport LIMIT 100
09:50:18,900 DEBUG [org.teiid.CONNECTOR] (Worker0_QueryProcessorQueue2)
ZzVxT/W8iN+B.0.0.0 Closed execution
{code}
The vdb looks like:
{code:xml}
<vdb name="jdg-local" version="1">
<description>For testing of materialized views</description>
<property name ="lib" value
="org.jboss.qe.jdg.pojos"></property>
<model name="jdgSource">
<source name="jdgSource" translator-name="jdg-override"
connection-jndi-name="java:/jdg-mat-ds" />
<metadata type="DDL"><![CDATA[]]>
CREATE FOREIGN TABLE CustomerReport(
customerId integer not null OPTIONS (SEARCHABLE 'Searchable', NATIVE_TYPE
'int'),
totalAmount integer,
CONSTRAINT PK_ID PRIMARY KEY(customerId)
) OPTIONS (NAMEINSOURCE 'jdg-mat', UPDATABLE TRUE);
</metadata>
</model>
<translator name="jdg-override" type="infinispan-cache">
<property name="SupportsDSLSearching" value="true"/>
<property name="SupportsDirectQueryProcedure" value="true"
/>
</translator>
</vdb>
{code}
And the annotated POJO:
{code:java}
@Indexed
public class CustomerReport implements Serializable {
private static final long serialVersionUID = 1L;
@NumericField @Field(index=Index.YES, store=Store.YES, analyze=Analyze.NO)
private Integer customerId;
@Field(index=Index.YES, store=Store.YES, analyze=Analyze.NO)
private Integer totalAmount;
public Integer getCustomerId() {
return customerId;
}
public void setCustomerId(Integer customerId) {
this.customerId = customerId;
}
public Integer getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(Integer totalAmount) {
this.totalAmount = totalAmount;
}
}
{code}
The cache is defined in infinispan-cfg.xml file:
{code:sql}
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:6.0
http://www.infinispan.org/schemas/infinispan-config-6.0.xsd"
xmlns="urn:infinispan:config:6.0">
<global>
<globalJmxStatistics enabled="false"
allowDuplicateDomains="true" />
</global>
<namedCache name="jdg-mat-stage">
<eviction strategy="LIRS" maxEntries="1000" />
<persistence passivation="false">
<singleFile shared="false" fetchPersistentState="false"
ignoreModifications="false" purgeOnStartup="false"
preload="false"
location="./target/localcache/indexing/jdg-mat-stage">
</singleFile>
</persistence>
</namedCache>
</infinispan>
{code}
Resource adapter looks like:
{code:xml}
<resource-adapter id="jdg-mat">
<module slot="6"
id="org.jboss.teiid.resource-adapter.infinispan"/>
<connection-definitions>
<connection-definition
class-name="org.teiid.resource.adapter.infinispan.InfinispanManagedConnectionFactory"
jndi-name="java:/jdg-mat-ds" enabled="true"
pool-name="jdg-mat">
<config-property
name="ConfigurationFileNameForLocalCache">
${jboss.home.dir}/standalone/configuration/infinispan-cfg.xml
</config-property>
<config-property name="CacheTypeMap">
jdg-mat:org.jboss.qe.jdg.pojo.CustomerReport;customerId
</config-property>
</connection-definition>
</connection-definitions>
</resource-adapter>
{code}