代码之家  ›  专栏  ›  技术社区  ›  dvlcis

点燃“sun.misc.Unsafe.park”线程异常并停止句柄请求

  •  0
  • dvlcis  · 技术社区  · 8 年前

    我有2个ignite客户端(2个IDEA项目在一台笔记本电脑上运行)+2个ignite服务器(2个linux vm)

    当我试图发送一些请求以从ignite缓存获取信息时,它会转储,但出现以下异常:

    [02:45:24,915][WARNING][grid-timeout-worker-#23][diagnostic] Found long running cache future [startTime=02:44:12.514, curTime=02:45:24.904, fut=GridNearAtomicSingleUpdateFuture [reqState=Primary [id=d42484f4-0e66-4e59-8258-7b10c6c41695, opRes=false, expCnt=-1, rcvdCnt=0, primaryRes=false, done=false, waitFor=null, rcvd=null], super=GridNearAtomicAbstractUpdateFuture [remapCnt=100, topVer=AffinityTopologyVersion [topVer=4, minorTopVer=0], remapTopVer=null, err=null, futId=92, super=GridFutureAdapter [ignoreInterrupts=false, state=INIT, res=null, hash=1812798386]]]]
    [02:45:25,004][WARNING][grid-timeout-worker-#23][G] >>> Possible starvation in striped pool.
        Thread name: sys-stripe-7-#8
        Queue: [Message closure [msg=GridIoMessage [plc=2, topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0, skipOnTimeout=false, msg=GridDhtAtomicSingleUpdateRequest [key=KeyCacheObjectImpl [part=239, val=null, hasValBytes=true], val=BinaryObjectImpl [arr= true, ctx=false, start=0], prevVal=null, super=GridDhtAtomicAbstractUpdateRequest [onRes=false, nearNodeId=null, nearFutId=0, flags=]]]], Message closure [msg=GridIoMessage [plc=2, topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0, skipOnTimeout=false, msg=GridNearAtomicUpdateResponse [nodeId=null, futId=92, errs=null, ret=GridCacheReturn [v=null, cacheObj=null, success=true, invokeRes=false, loc=true, cacheId=0], remapTopVer=null, nearUpdates=null, partId=239, mapping=null, nodeLeft=false, super=GridCacheIdMessage [cacheId=708740962]]]], Message closure [msg=GridIoMessage [plc=2, topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0, skipOnTimeout=false, msg=GridNearAtomicSingleUpdateRequest [key=KeyCacheObjectImpl [part=47, val=null, hasValBytes=true], super=GridNearAtomicSingleUpdateRequest [key=KeyCacheObjectImpl [part=47, val=null, hasValBytes=true], parent=GridNearAtomicAbstractSingleUpdateRequest [nodeId=null, futId=65569, topVer=AffinityTopologyVersion [topVer=4, minorTopVer=0], parent=GridNearAtomicAbstractUpdateRequest [res=null, flags=]]]]]], o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$DeferredUpdateTimeout@3f4991e7, Message closure [msg=GridIoMessage [plc=2, topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0, skipOnTimeout=false, msg=GridNearSingleGetRequest [futId=1524335645779, key=KeyCacheObjectImpl [part=119, val=null, hasValBytes=true], flags=1, topVer=AffinityTopologyVersion [topVer=4, minorTopVer=0], subjId=de46e275-9054-45ed-8e00-6ab2643a5904, taskNameHash=0, createTtl=-1, accessTtl=-1]]], Message closure [msg=GridIoMessage [plc=2, topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0, skipOnTimeout=false, msg=GridNearAtomicSingleUpdateRequest [key=KeyCacheObjectImpl [part=47, val=null, hasValBytes=true], super=GridNearAtomicSingleUpdateRequest [key=KeyCacheObjectImpl [part=47, val=null, hasValBytes=true], parent=GridNearAtomicAbstractSingleUpdateRequest [nodeId=null, futId=16417, topVer=AffinityTopologyVersion [topVer=4, minorTopVer=0], parent=GridNearAtomicAbstractUpdateRequest [res=null, flags=]]]]]]]
        Deadlock: false
        Completed: 73
    Thread [name="sys-stripe-7-#8", id=19, state=WAITING, blockCnt=0, waitCnt=108]
            at sun.misc.Unsafe.park(Native Method)
            at java.util.concurrent.locks.LockSupport.park(LockSupport.java:304)
            at o.a.i.i.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:177)
            at o.a.i.i.util.future.GridFutureAdapter.get(GridFutureAdapter.java:140)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put0(GridDhtAtomicCache.java:613)
            at o.a.i.i.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2369)
            at o.a.i.i.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2346)
            at o.a.i.i.processors.cache.IgniteCacheProxyImpl.put(IgniteCacheProxyImpl.java:1026)
            at o.a.i.i.processors.cache.GatewayProtectedCacheProxy.put(GatewayProtectedCacheProxy.java:886)
            at com.test.match.MarketEventHandler.genReport(MarketEventHandler.java:67)
            at com.test.match.TestMatchBasicExecutor.matchCurrentLevel(TestMatchBasicExecutor.java:225)
            at com.test.match.TestMatchBasicExecutor$matchEntryProcessor.process(TestMatchBasicExecutor.java:469)
            at com.test.match.TestMatchBasicExecutor$matchEntryProcessor.process(TestMatchBasicExecutor.java:408)
            at o.a.i.i.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.runEntryProcessor(GridCacheMapEntry.java:5142)
            at o.a.i.i.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:4550)
            at o.a.i.i.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:4367)
            at o.a.i.i.processors.cache.persistence.tree.BPlusTree$Invoke.invokeClosure(BPlusTree.java:3051)
            at o.a.i.i.processors.cache.persistence.tree.BPlusTree$Invoke.access$6200(BPlusTree.java:2945)
            at o.a.i.i.processors.cache.persistence.tree.BPlusTree.invokeDown(BPlusTree.java:1717)
            at o.a.i.i.processors.cache.persistence.tree.BPlusTree.invoke(BPlusTree.java:1600)
            at o.a.i.i.processors.cache.IgniteCacheOffheapManagerImpl$CacheDataStoreImpl.invoke(IgniteCacheOffheapManagerImpl.java:1199)
            at o.a.i.i.processors.cache.IgniteCacheOffheapManagerImpl.invoke(IgniteCacheOffheapManagerImpl.java:345)
            at o.a.i.i.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:1767)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2420)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update(GridDhtAtomicCache.java:1883)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1736)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(GridDhtAtomicCache.java:1628)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.processNearAtomicUpdateRequest(GridDhtAtomicCache.java:3055)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.access$400(GridDhtAtomicCache.java:130)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$5.apply(GridDhtAtomicCache.java:266)
            at o.a.i.i.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$5.apply(GridDhtAtomicCache.java:261)
            at o.a.i.i.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:1060)
            at o.a.i.i.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:579)
            at o.a.i.i.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:378)
            at o.a.i.i.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:304)
            at o.a.i.i.processors.cache.GridCacheIoManager.access$100(GridCacheIoManager.java:99)
            at o.a.i.i.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:293)
            at o.a.i.i.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1555)
            at o.a.i.i.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1183)
            at o.a.i.i.managers.communication.GridIoManager.access$4200(GridIoManager.java:126)
            at o.a.i.i.managers.communication.GridIoManager$9.run(GridIoManager.java:1090)
            at o.a.i.i.util.StripedExecutor$Stripe.run(StripedExecutor.java:505)
            at java.lang.Thread.run(Thread.java:748)
    

    上述代码例外情况如下:

    // TestMatchBasicExecutor.java:469
    private static class matchEntryProcessor implements EntryProcessor<
        String, TestTradeCoinInfo, TestTradeCoinInfo> {
    
    @Override
    public TestTradeCoinInfo process(
            MutableEntry<String, TestTradeCoinInfo> entry, Object... args) {
    
        Ignite ignite = (Ignite) args[0];
        TestMatchEntrustInfo testMatchEntrustInfo = (TestMatchEntrustInfo) args[1];
        TestMatchEventHandler handler = (TestMatchEventHandler) args[2];
    
        TestTradeCoinInfo testTradeCoinInfo = entry.getValue();
    
    ...
        // TestMatchBasicExecutor.java:469
        if (false == matchTest(testMatchEntrustInfo, priceLevel, handler)) { 
            return null;
        }
    
    ...
    
        entry.setValue(testTradeCoinInfo);
    
        return null;
    }
    }
    
    
    
    public static boolean matchTest(TestMatchEntrustInfo testInfo,
                                        MatchPriceLevel matchPriceLevel,
                                        TestMatchEventHandler eventHandler) {
    ...
    
    eventHandler.genReport(testInfo,
            pendingInfo,
            amount,
            price);
    
    ...
    
    }
    
    
    public void genReport(TestMatchEntrustInfo primary, TestMatchEntrustInfo pending,
                      BigDecimal amount, BigDecimal price) {
    
    String txCoinType = primary.getTxCoinType();
    
    TestMatchResultRecord record = new TestMatchResultRecord();
    record.genMatchResultRecord(primary, pending, amount, price);
    
    // Add to another queue, and exit quickly to avoid dead lock
    IgniteQueue<TestMatchResultRecord> reportQueue =
            ignite.queue("ResultRecordQueue_" + txCoinType, 0, null);
    reportQueue.put(record);
    
    }
    

    我使用ignite EntryProcessor来处理我的数据,之前在genReport中,它还有另一个缓存使用EntryProcessor,它总是失败,所以我使用 ignite queue将记录保存到队列并在另一个服务线程中处理该记录,但在更改后,它会给出abvoe异常,并拒绝再处理任何其他请求

    1 回复  |  直到 7 年前
        1
  •  2
  •   Valentin Kulichenko    8 年前

    您不应该执行同步 put() EntryProcessor 。处理器已在锁中调用,因此这可能会导致死锁和/或线程不足。

    如果需要更新已处理的条目,请使用 MutableEntry#setValue(..)

    推荐文章