Serialization Exception when trying to query cache on remote node.

classic Classic list List threaded Threaded
5 messages Options
pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Serialization Exception when trying to query cache on remote node.

asked by john smith

I though I would start a fresh question and make sure I didn't fudge up renaming my types before posting in public location.

Using 1.0.

When I run a query on a remote node, I get a serialization exception...

Apr 14, 2015 4:18:27 PM org.apache.ignite.logger.java.JavaLogger error
SEVERE: Error sending reply for job [nodeId=e265c5c8-d18b-4ce9-9d36-5be1bdf774e7, jobId=769f499bc41-7adb4843-c99d-4896-8aea-284f53366934, ses=GridJobSessionImpl [ses=GridTaskSessionImpl [taskName=com.xxx.service.MyService2$$Lambda$69/1280666626, dep=LocalDeployment [super=GridDeployment [ts=1429042694671, depMode=SHARED, clsLdr=sun.misc.Launcher$AppClassLoader@55f96302, clsLdrId=f0a0599bc41-7adb4843-c99d-4896-8aea-284f53366934, userVer=0, loc=true, sampleClsName=java.lang.String, pendingUndeploy=false, undeployed=false, usage=0]], taskClsName=com.xxx.service.MyService2$$Lambda$69/1280666626, sesId=669f499bc41-e265c5c8-d18b-4ce9-9d36-5be1bdf774e7, startTime=1429042707780, endTime=9223372036854775807, taskNodeId=e265c5c8-d18b-4ce9-9d36-5be1bdf774e7, clsLdr=sun.misc.Launcher$AppClassLoader@55f96302, closed=false, cpSpi=null, failSpi=null, loadSpi=null, usage=1, fullSup=false, subjId=e265c5c8-d18b-4ce9-9d36-5be1bdf774e7, mapFut=IgniteFuture [orig=GridFutureAdapter [resFlag=0, res=null, startTime=1429042707735, endTime=0, lsnr=null, state=INIT]]], jobId=769f499bc41-7adb4843-c99d-4896-8aea-284f53366934], job=C1 [arg=com.xxx.model.MyTrx2@4a62b3dd]]
class org.apache.ignite.IgniteCheckedException: Failed to serialize object: [Entry [key=3, val=com.xxx.model.MyTrx2@552381d5]]
    at org.apache.ignite.marshaller.optimized.OptimizedMarshaller.marshal(OptimizedMarshaller.java:186)
    at org.apache.ignite.internal.processors.job.GridJobWorker.finishJob(GridJobWorker.java:706)
    at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:527)
    at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:423)
    at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:107)
    at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1118)
    at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1714)
    at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:664)
    at org.apache.ignite.internal.managers.communication.GridIoManager.access$1500(GridIoManager.java:57)
    at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:627)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.NotSerializableException: Must implement java.io.Serializable or set OptimizedMarshaller.setRequireSerializable() to false (note that performance may degrade if object is not Serializable): org.apache.ignite.internal.processors.cache.CacheEntryImpl
    at org.apache.ignite.marshaller.optimized.OptimizedClassDescriptor.write(OptimizedClassDescriptor.java:703)
    at org.apache.ignite.marshaller.optimized.OptimizedObjectOutputStream.writeObject0(OptimizedObjectOutputStream.java:217)
    at org.apache.ignite.marshaller.optimized.OptimizedObjectOutputStream.writeHashMap(OptimizedObjectOutputStream.java:357)
    at org.apache.ignite.marshaller.optimized.OptimizedObjectOutputStream.writeHashSet(OptimizedObjectOutputStream.java:373)
    at org.apache.ignite.marshaller.optimized.OptimizedClassDescriptor.write(OptimizedClassDescriptor.java:655)
    at org.apache.ignite.marshaller.optimized.OptimizedObjectOutputStream.writeObject0(OptimizedObjectOutputStream.java:217)
    at org.apache.ignite.marshaller.optimized.OptimizedObjectOutputStream.writeObjectOverride(OptimizedObjectOutputStream.java:131)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at org.apache.ignite.marshaller.optimized.OptimizedMarshaller.marshal(OptimizedMarshaller.java:181)
    ... 12 more

This is how I query: http://pastebin.com/9ipi3q2u The model: http://pastebin.com/MbH2cL3H

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss

pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Re: Serialization Exception when trying to query cache on remote node.

commented by alexey goncharuk

John,

You do not need to broadcast a closure which executes your SQL query on all nodes. In fact, this is essentially what happens under the covers when you ask Ignite to execute an SQL query.

In your case, you should get rid of broadcast(...) call altogether and run

String sqlStr = "FROM MyTrx2 WHERE fullName = ?";
SqlQuery sql = new SqlQuery(MyTrx2.class, sqlStr);
sql.setArgs(trxRequest.getFullName());
sql.setLocal(true);
HashSet<Map.Entry> list = new HashSet<>(myCache.query(sql.setSql(sqlStr)).getAll());


right away instead.

As a side note notice that I changed the generic type of the hash set because an SQL query returns collection of Map.Entry objects.

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss

pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Re: Serialization Exception when trying to query cache on remote node.

commented by john smith

I want to execute where fullName = ? or someField = ?

Or queries are very slow based on how H2 indexes work. And H2 site suggests to use UNION queries to do an OR query but UNION is broken in 1.0 release.

So I was thinking I want to run 2 queries in parallel. What would be the best way?

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss

pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Re: Serialization Exception when trying to query cache on remote node.

This post was updated on .
commented by dmitriy setrakyan

John, can you set OptimizedMasshaller.setRequireSerializable(false) property?

OptimizedMarshaller marsh = new OptimizedMarshaller();

marsh.setRequireSerializable(false);

IgniteConfiguration cfg = new IgniteConfiguration();

cfg.setMarshaller(marsh);

Ignite ignite = Ignition.start(cfg);


It turns out that Cache.Entry interface returned by quire (JCache API) is not Serializable. We will make the class implementing this interface Serializable in the next release.

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss

pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Re: Serialization Exception when trying to query cache on remote node.

commented by dmitriy setrakyan

John, I also recommend that you download the GridGain Community Edition of Apache Ignite. It contains fixes for the Union queries.

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss