失败后如何恢复写入队列

时间:2019-08-23 08:49:57

标签: chronicle chronicle-queue

磁盘空间完成后,我收到了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)

1 个答案:

答案 0 :(得分:0)

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

PS,您实际上不需要执行惰性获取逻辑。您始终可以简单地执行queue.acquireAppender()-这是一个便宜的调用,它从ThreadLocal池中获取预先存在的附加程序,并且每次都会创建新的附加程序。