gridgain / gridgain-old

267 stars 85 forks source link

After a few runs, throws ClassCastException: org.gridgain.grid.kernal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache cannot be cast to org.gridgain.grid.kernal.processors.cache.distributed.near.GridNearCacheAdapter #78

Open ceefour opened 10 years ago

ceefour commented 10 years ago

Java8 code: (https://github.com/ceefour/lumen-kb/blob/e50b8fc0690c078fcec1c037be9496f1dc10937f/cli/src/main/java/id/ac/itb/ee/lskk/lumen/yago/YagoLabelLookupCli.java)

String upLabel = "Muhammad";

try (Grid grid = GridGain.start(YagoLabelLookupCli.class.getResource("yago.gridgain.xml"))) {
    GridCache<String, String> labelCache = grid.cache("yagoLabel");
//          labelCache.queries().createScanQuery(null).execute((GridClosure<Entry<String, String>, String>) (it) ->
//              it.getValue().equalsIgnoreCase(upLabel) ? it.getKey() : null);
    log.info("Finding resource for label '{}'...", upLabel);
    Collection<String> founds = labelCache.queries().createScanQuery(null).execute(new GridReducer<Entry<String, String>, String>() {
        String id;

        @Override
        public boolean collect(Entry<String, String> e) {
            if (e.getValue().equalsIgnoreCase(upLabel)) {
                id = e.getKey();
                return false;
            } else {
                return true;
            }
        }

        @Override
        public String reduce() {
            return id;
        }
    }).get();

    log.info("Found for {}: {}", upLabel, founds);
}

After a few edits and runs, GridGain throws the following error. This error never happens on the first invocation (i.e. after starting 2 nodes, then running the compute)

[13:04:20]   _____     _     _______      _         
[13:04:20]  / ___/____(_)___/ / ___/___ _(_)___     
[13:04:20] / (_ // __/ // _  / (_ // _ `/ // _ \   
[13:04:20] \___//_/ /_/ \_,_/\___/ \_,_/_//_//_/
[13:04:20]  
[13:04:20] ver. 6.1.9-os#20140627-sha1:88a243e1
[13:04:20] 2014 Copyright (C) GridGain Systems
[13:04:20] 
[13:04:20] Quiet mode.
[13:04:20]   ^-- Logging to file '/tmp/gridgain/work/log/gridgain-1115d1df.%g.log'
[13:04:20]   ^-- To see **FULL** console log here add -DGRIDGAIN_QUIET=false or "-v" to ggstart.{sh|bat}
[13:04:20] 
[13:04:20] Failed to create Protobuf marshaller for REST C++ and .NET clients (consider adding gridgain-protobuf module to classpath).
[13:04:20] Failed to initialize HTTP REST protocol (consider adding gridgain-rest-http module to classpath).
[13:04:29] Performance suggestions for grid  (fix if possible)
[13:04:29] To disable, set -DGRIDGAIN_PERFORMANCE_SUGGESTIONS_DISABLED=true
[13:04:29]   ^-- Decrease number of backups (set 'keyBackups' to 0)
[13:04:29]   ^-- Disable fully synchronous writes (set 'writeSynchronizationMode' to PRIMARY_SYNC or FULL_ASYNC)
[13:04:29]   ^-- Enable write-behind to persistent store (set 'writeBehindEnabled' to true)
[13:04:29]   ^-- Disable query index (set 'queryIndexEnabled' to false)
[13:04:29]   ^-- Disable peer class loading (set 'peerClassLoadingEnabled' to false)
[13:04:29]   ^-- Disable grid events (remove 'includeEventTypes' from configuration)
[13:04:29] 
[13:04:29] If running benchmarks, see http://bit.ly/GridGain-Benchmarking
[13:04:29] To start Console Management & Monitoring run ggvisorcmd.{sh|bat}
[13:04:29] 
[13:04:29] GridGain node started OK (id=1115d1df)
[13:04:29] Topology snapshot [ver=11, nodes=3, CPUs=4, heap=3.0GB]
13:04:29.331 [main] INFO  i.a.i.e.l.l.yago.YagoLabelLookupCli - Finding resource for label 'Muhammad'...
[13:04:31] GridGain node stopped OK [uptime=00:00:02:190]
Exception in thread "main" class org.gridgain.grid.GridException: Failed to execute query on node [query=org.gridgain.grid.kernal.processors.cache.query.GridCacheQueryBean@4ecb515f, nodeId=8f692cc9-2185-4a56-9167-3ba413114f89]
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheQueryFutureAdapter.onPage(GridCacheQueryFutureAdapter.java:308)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheDistributedQueryManager.processQueryResponse(GridCacheDistributedQueryManager.java:356)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheDistributedQueryManager.access$000(GridCacheDistributedQueryManager.java:49)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheDistributedQueryManager$1.apply(GridCacheDistributedQueryManager.java:79)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheDistributedQueryManager$1.apply(GridCacheDistributedQueryManager.java:77)
    at org.gridgain.grid.kernal.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:298)
    at org.gridgain.grid.kernal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:230)
    at org.gridgain.grid.kernal.processors.cache.GridCacheIoManager.access$200(GridCacheIoManager.java:49)
    at org.gridgain.grid.kernal.processors.cache.GridCacheIoManager$OrderedMessageListener.onMessage(GridCacheIoManager.java:801)
    at org.gridgain.grid.kernal.managers.communication.GridIoManager.unwindMessageSet(GridIoManager.java:838)
    at org.gridgain.grid.kernal.managers.communication.GridIoManager.processOrderedMessage0(GridIoManager.java:800)
    at org.gridgain.grid.kernal.managers.communication.GridIoManager.access$1900(GridIoManager.java:62)
    at org.gridgain.grid.kernal.managers.communication.GridIoManager$7.body(GridIoManager.java:675)
    at org.gridgain.grid.util.worker.GridWorker.run(GridWorker.java:151)
    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: class org.gridgain.grid.GridRuntimeException: org.gridgain.grid.kernal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache cannot be cast to org.gridgain.grid.kernal.processors.cache.distributed.near.GridNearCacheAdapter
For more information see:
    Troubleshooting:      http://bit.ly/GridGain-Troubleshooting
    Documentation Center: http://bit.ly/GridGain-Documentation

    at org.gridgain.grid.kernal.processors.cache.GridCacheAdapter.peek0(GridCacheAdapter.java:743)
    at org.gridgain.grid.kernal.processors.cache.GridCacheAdapter.peek(GridCacheAdapter.java:4211)
    at org.gridgain.grid.kernal.processors.cache.GridCacheProjectionImpl.peek(GridCacheProjectionImpl.java:949)
    at org.gridgain.grid.kernal.processors.cache.GridCacheProxyImpl.peek(GridCacheProxyImpl.java:1246)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheQueryManager.scanIterator(GridCacheQueryManager.java:564)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheQueryManager.executeQuery(GridCacheQueryManager.java:448)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheQueryManager.queryIterator(GridCacheQueryManager.java:1038)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheQueryManager.queryIterator(GridCacheQueryManager.java:1005)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheQueryManager.runQuery(GridCacheQueryManager.java:844)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheDistributedQueryManager.processQueryRequest(GridCacheDistributedQueryManager.java:176)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheDistributedQueryManager$2.apply(GridCacheDistributedQueryManager.java:91)
    at org.gridgain.grid.kernal.processors.cache.query.GridCacheDistributedQueryManager$2.apply(GridCacheDistributedQueryManager.java:89)
    at org.gridgain.grid.kernal.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:298)
    at org.gridgain.grid.kernal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:230)
    at org.gridgain.grid.kernal.processors.cache.GridCacheIoManager.access$200(GridCacheIoManager.java:49)
    at org.gridgain.grid.kernal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:142)
    at org.gridgain.grid.kernal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:654)
    at org.gridgain.grid.kernal.managers.communication.GridIoManager.access$1800(GridIoManager.java:62)
    at org.gridgain.grid.kernal.managers.communication.GridIoManager$6.body(GridIoManager.java:615)
    ... 4 more
Caused by: class org.gridgain.grid.GridException: org.gridgain.grid.kernal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache cannot be cast to org.gridgain.grid.kernal.processors.cache.distributed.near.GridNearCacheAdapter
For more information see:
    Troubleshooting:      http://bit.ly/GridGain-Troubleshooting
    Documentation Center: http://bit.ly/GridGain-Documentation

    at org.gridgain.grid.util.GridUtils.cast(GridUtils.java:6518)
    at org.gridgain.grid.kernal.processors.cache.GridCacheContext.isAll(GridCacheContext.java:1004)
    at org.gridgain.grid.kernal.processors.cache.GridCacheMapEntry.peekGlobal(GridCacheMapEntry.java:2476)
    at org.gridgain.grid.kernal.processors.cache.GridCacheMapEntry.peek0(GridCacheMapEntry.java:2335)
    at org.gridgain.grid.kernal.processors.cache.GridCacheAdapter.peek0(GridCacheAdapter.java:719)
    ... 22 more
Caused by: java.lang.ClassCastException: org.gridgain.grid.kernal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache cannot be cast to org.gridgain.grid.kernal.processors.cache.distributed.near.GridNearCacheAdapter
    at org.gridgain.grid.kernal.processors.cache.GridCacheContext.near(GridCacheContext.java:474)
    at org.gridgain.grid.kernal.processors.cache.distributed.GridPartitionedCacheEntryImpl.near(GridPartitionedCacheEntryImpl.java:82)
    at org.gridgain.grid.kernal.processors.cache.distributed.GridPartitionedCacheEntryImpl.peekEx(GridPartitionedCacheEntryImpl.java:271)
    at org.gridgain.grid.kernal.processors.cache.GridCacheEntryImpl.unwrapNoCreate(GridCacheEntryImpl.java:110)
    at org.gridgain.grid.kernal.processors.cache.GridCacheEntryImpl.peek0(GridCacheEntryImpl.java:315)
    at org.gridgain.grid.kernal.processors.cache.GridCacheEntryImpl.peek0(GridCacheEntryImpl.java:365)
    at org.gridgain.grid.kernal.processors.cache.GridCacheEntryImpl.peek(GridCacheEntryImpl.java:272)
    at org.gridgain.grid.kernal.processors.cache.distributed.GridPartitionedCacheEntryImpl.peek(GridPartitionedCacheEntryImpl.java:109)
    at org.gridgain.grid.kernal.processors.cache.GridCacheEntryImpl.peek(GridCacheEntryImpl.java:262)
    at org.gridgain.grid.kernal.processors.cache.GridCacheProjectionImpl$FullFilter.apply(GridCacheProjectionImpl.java:1312)
    at org.gridgain.grid.kernal.processors.cache.GridCacheProjectionImpl$FullFilter.apply(GridCacheProjectionImpl.java:1290)
    at org.gridgain.grid.util.lang.GridFunc.isAll(GridFunc.java:6016)
    at org.gridgain.grid.kernal.processors.cache.GridCacheContext.isAll(GridCacheContext.java:995)
    ... 25 more
dsetrakyan commented 10 years ago

We are trying to reproduce this issue. Can you provide content of your yago.gridgain.xml configuration file? You can use http://pastebin.com/ to paste your code.

ceefour commented 10 years ago

Sure, here's it: https://github.com/ceefour/lumen-kb/blob/e50b8fc0690c078fcec1c037be9496f1dc10937f/cli/src/main/resources/id/ac/itb/ee/lskk/lumen/yago/yago.gridgain.xml

If I can find reproducible steps I'll let you know.

agoncharuk commented 10 years ago

This is a pretty rare bug which is reproduced when using full-scan query on changing topology. It was fixed and will be available in upcoming 6.2.0 release. As a workaround, you can now enable NEAR_PARTITIONED distribution mode on all nodes, or start your 'client' node that initiates query in CLIENT_ONLY or NEAR_ONLY distribution mode.

ceefour commented 10 years ago

Thank you! Wow, you're good...