Barrett Oglesby created GEODE-7957:
--------------------------------------
Summary: Serializing and deserializing a
CumulativeNonDistinctResults containing Structs fails with either an
OutOfMemoryError or an IllegalArgumentException
Key: GEODE-7957
URL: https://issues.apache.org/jira/browse/GEODE-7957
Project: Geode
Issue Type: Bug
Components: querying
Reporter: Barrett Oglesby
Executing a query like:
{noformat}
SELECT pnl.TM_ID, pnl.PTD_ACCRETION_INV_AMT, pnl.FIRM_ACCT_ID, pnl.INSM_ID,
adj.PL_POSN_ID , adj.DLY_ACCRETION_INV_AMT FROM /PnLPosition4 pnl ,
/AdjustmentPosition4 adj where adj.PL_POSN_ID = pnl.PL_POSN_ID
{noformat}
Using a function that does:
{noformat}
QueryService queryService = CacheFactory.getAnyInstance().getQueryService();
Query query = queryService.newQuery(queryStr);
SelectResults results = (SelectResults) query.execute(rfc);
context.getResultSender().lastResult(results);
{noformat}
Causes one of two exceptions when the CumulativeNonDistinctResults is
deserialized.
Either an IllegalArgumentException on the client like:
{noformat}
Caused by: java.lang.IllegalArgumentException: unexpected typeCode: 46
at
org.apache.geode.internal.serialization.StaticSerialization.decodePrimitiveClass(StaticSerialization.java:502)
at
org.apache.geode.DataSerializer.readObjectArray(DataSerializer.java:1744)
at
org.apache.geode.cache.query.internal.CumulativeNonDistinctResults.fromData(CumulativeNonDistinctResults.java:293)
at
org.apache.geode.internal.serialization.internal.DSFIDSerializerImpl.invokeFromData(DSFIDSerializerImpl.java:332)
at
org.apache.geode.internal.serialization.internal.DSFIDSerializerImpl.create(DSFIDSerializerImpl.java:383)
{noformat}
Or an OutOfMemoryError on the server like:
{noformat}
java.lang.OutOfMemoryError: Java heap space
at java.util.ArrayList.<init>(ArrayList.java:152)
at
org.apache.geode.cache.query.internal.CumulativeNonDistinctResults.fromData(CumulativeNonDistinctResults.java:289)
at
org.apache.geode.internal.serialization.internal.DSFIDSerializerImpl.invokeFromData(DSFIDSerializerImpl.java:332)
at
org.apache.geode.internal.serialization.internal.DSFIDSerializerImpl.create(DSFIDSerializerImpl.java:383)
at org.apache.geode.internal.DSFIDFactory.create(DSFIDFactory.java:1018)
at
org.apache.geode.internal.InternalDataSerializer.basicReadObject(InternalDataSerializer.java:2508)
at org.apache.geode.DataSerializer.readObject(DataSerializer.java:2864)
{noformat}
CumulativeNonDistinctResults.toData does:
{noformat}
HeapDataOutputStream hdos = new HeapDataOutputStream(1024, null);
LongUpdater lu = hdos.reserveLong();
...
DataSerializer.writeObjectArray(fields, out);
...
lu.update(numElements);
{noformat}
NWayMergeResults.toData is broken in the same way
The fix is to write the fields to hdos instead of out like:
{noformat}
DataSerializer.writeObjectArray(fields, hdos);
{noformat}
A work-around in the function is to convert the CumulativeNonDistinctResults to
a List like:
{noformat}
context.getResultSender().lastResult(results.asList());
{noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)