首页 > 解决方案 > 失败后如何恢复写入队列

问题描述

磁盘空间完成后,我得到了 InternalError。添加磁盘空间并不能解决问题。


是否有可能恢复并继续坚持?
可能出错我可以尝试重新创建/关闭吗?

的创建queue queue = SingleChronicleQueueBuilder.binary(basePath) .build();

在单线程上写入“TradeReactorEventPersister-1”

    ExcerptAppender appender = acquireAppender;
    if (appender == null) {
        appender = queue.acquireAppender();
        acquireAppender = appender;
    }
    appender.writeBytes(BytesStore.wrap(b));

在下一个例外之后:

2019-08-23 08:13:26.963 +0000 ERROR [TradeReactorEventPersister-1] LoggingUncaughtExceptionHandler - Uncaught exception a fault occurred in a recent unsafe memory access operation in compiled Java code in thread TradeReactorEventPersister-1 
java.lang.InternalError: a fault occurred in a recent unsafe memory access operation in compiled Java code
        at net.openhft.chronicle.wire.AbstractWire.updateHeaderAssertions(AbstractWire.java:546)
        at net.openhft.chronicle.wire.AbstractWire.updateHeader(AbstractWire.java:533)
        at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeBytes(SingleChronicleQueueExcerpts.java:470)

2019-08-23 08:13:26.965 +0000 ERROR [TradeReactorEventPersister-1] LoggingUncaughtExceptionHandler - Uncaught exception a fault occurred in a recent unsafe memory access operation in compiled Java code in thread TradeReactorEventPersister-1 
java.lang.InternalError: a fault occurred in a recent unsafe memory access operation in compiled Java code
        at net.openhft.chronicle.wire.AbstractWire.updateHeaderAssertions(AbstractWire.java:547)
        at net.openhft.chronicle.wire.AbstractWire.updateHeader(AbstractWire.java:533)
        at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeBytes(SingleChronicleQueueExcerpts.java:470)

2019-08-23 08:13:27.166 +0000 ERROR [TradeReactorEventPersister-1] LoggingUncaughtExceptionHandler - Uncaught exception a fault occurred in a recent unsafe memory access operation in compiled Java code in thread TradeReactorEventPersister-1 
java.lang.InternalError: a fault occurred in a recent unsafe memory access operation in compiled Java code
        at net.openhft.chronicle.wire.AbstractWire.updateHeader(AbstractWire.java:511)
        at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeBytes(SingleChronicleQueueExcerpts.java:470)

2019-08-23 08:13:27.167 +0000 ERROR [TradeReactorEventPersister-1] LoggingUncaughtExceptionHandler - Uncaught exception you cant put a header inside a header, check that you have not nested the documents. If you are using Chronicle-Queue please ensure that you have a unique instance of the Appender per thread, in other-words you can not share appenders across threads. in thread TradeReactorEventPersister-1 
java.lang.AssertionError: you cant put a header inside a header, check that you have not nested the documents. If you are using Chronicle-Queue please ensure that you have a unique instance of the Appender per thread, in other-words you can not share appenders across threads.
        at net.openhft.chronicle.wire.AbstractWire.enterHeader(AbstractWire.java:322)
        at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeHeader(SingleChronicleQueueExcerpts.java:405)
        at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeBytes(SingleChronicleQueueExcerpts.java:463)

添加磁盘空间后我无法坚持。每次尝试持久化事件时,我都遇到了最后一个异常:

2019-08-23 08:22:50.746 +0000 ERROR [TradeReactorEventPersister-1] LoggingUncaughtExceptionHandler - Uncaught exception you cant put a header inside a header, check that you have not nested the documents. If you are using Chronicle-Queue please ensure that you have a unique instance of the Appender per thread, in other-words you can not share appenders across threads. in thread TradeReactorEventPersister-1 
java.lang.AssertionError: you cant put a header inside a header, check that you have not nested the documents. If you are using Chronicle-Queue please ensure that you have a unique instance of the Appender per thread, in other-words you can not share appenders across threads.
        at net.openhft.chronicle.wire.AbstractWire.enterHeader(AbstractWire.java:322)
        at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeHeader(SingleChronicleQueueExcerpts.java:405)
        at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeBytes(SingleChronicleQueueExcerpts.java:463)

标签: chroniclechronicle-queue

解决方案


不幸的是,编年史队列工作在相当低的级别,并且在数据损坏后无法自动修复(磁盘空间不可避免地会导致数据损坏)。顺便说一句,为了避免这种情况,如果您的磁盘空间不足,Chronicle Queue 会警告您,您应该看到如下警告消息: "your disk " + this.fileStore + " is almost full, warning: chronicle-queue may crash if it runs out of space."

PS你不应该真的需要做惰性获取逻辑。您总是可以简单地执行 queue.acquireAppender() - 这是一个廉价的调用,它从 ThreadLocal 池中获取预先存在的 appender,并且不会每次都创建新的 appender。


推荐阅读