question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.IllegalStateException: Unable to index 268435456

See original GitHub issue

With the attached appender and tailer after ~268M messages I get the following exception

Exception in thread "main" java.lang.IllegalStateException: Unable to index 268435456
	at net.openhft.chronicle.queue.impl.single.SCQIndexing.setPositionForSequenceNumber(SCQIndexing.java:625)
	at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueStore.setPositionForSequenceNumber(SingleChronicleQueueStore.java:350)
	at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeIndexForPosition(SingleChronicleQueueExcerpts.java:689)
	at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender$StoreAppenderContext.close(SingleChronicleQueueExcerpts.java:818)
	at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender$StoreAppenderContext.close(SingleChronicleQueueExcerpts.java:784)
	at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreAppender.writeBytes(SingleChronicleQueueExcerpts.java:174)
	at bitmex.gateway.trading.engine.chronicle.TimestampAppender.main(TimestampAppender.java:21)

And at that point the queue is corrupt.

import net.openhft.chronicle.queue.ExcerptAppender;
import net.openhft.chronicle.queue.RollCycles;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueue;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;

public class TimestampAppender {

    public static void main(String[] args) {

        SingleChronicleQueue build = SingleChronicleQueueBuilder
                .binary("src/test/resources/sandbox/times_publication")
                .rollCycle(RollCycles.HOURLY)
                .timeProvider(System::currentTimeMillis)
                .build();

        ExcerptAppender excerptAppender = build.acquireAppender().methodWriterBuilder().recordHistory();

        while (true) {
            excerptAppender.writeBytes(bytesOut -> {
                bytesOut.writeLong(System.nanoTime());
            });
        }
    }
}
import net.openhft.chronicle.queue.ExcerptTailer;
import net.openhft.chronicle.queue.RollCycles;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueue;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;
import net.openhft.chronicle.wire.DocumentContext;

public class TimestampTailer {

    public static void main(String[] args) throws InterruptedException {
        SingleChronicleQueue build = SingleChronicleQueueBuilder
                .binary("src/test/resources/sandbox/times_publication")
                .rollCycle(RollCycles.HOURLY)
                .timeProvider(System::currentTimeMillis)
                .build();

        ExcerptTailer tailer = build.createTailer();

        long previousTimestamp = 0;
        long counter = 0;

        while (true) {
            try (DocumentContext documentContext = tailer.readingDocument()) {
                if (!documentContext.isPresent()) {
                    Thread.sleep(1);
                    continue;
                }

                long timestamp = documentContext.wire().bytes().readLong();
                if (timestamp < previousTimestamp) {
                    throw new RuntimeException();
                }

                ++counter;
                if (counter % 1000000 == 0) {
                    System.out.println("Seen " + counter + " events");
                }

                previousTimestamp = timestamp;
            }
        }
    }
}

uname -a: Darwin MacBook-Pro 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64 JDK:

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (Zulu 8.46.0.19-CA-macosx) (build 1.8.0_252-b14)
OpenJDK 64-Bit Server VM (Zulu 8.46.0.19-CA-macosx) (build 25.252-b14, mixed mode)

Chronicle 5.19.32

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dpisklovcommented, Jun 10, 2020

@mikeb01 the time is in the name of the roll cycle. Queue rolls starting from midnight UTC, so e.g. for *HOURLY roll cycles (there’re few) the roll will happen at the hour boundary. As for the number of messages left, it’s max number of messages per roll cycle minus current sequence number (RollCycle#toSequenceNumber(long) can help you to convert output of appender#index() or tailer#index() to the sequence number within the current roll cycle)

0reactions
mikeb01commented, Jun 12, 2020

I can confirm that the queue is not corrupt, it was just continuing to through the IllegalStateException until the hourly rollover.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot start Elasticsearch with non loopback address #19987
Elasticsearch.main(Elasticsearch.java:68) Suppressed: java.lang.IllegalStateException: initial heap size [268435456] not equal to maximum ...
Read more >
Android:java.lang.OutOfMemoryError: Failed to allocate a ...
This error is thrown by the Java Virtual Machine (JVM) when an object cannot be allocated due to lack of memory space and...
Read more >
After server reboot, JIRA 7.3.1 does not start
LauncherContextListener] Unable to start JIRA. java.lang.IllegalStateException: Abnormal system startup detected at com.atlassian.jira.startup.
Read more >
Crash when lauching app on Android 11 - I'm Stuck
I'm stuck when I try to open my app on Android 11. ... [GL_OOM] limited APP ClampGrowthLimit, set size to 268435456 05-23 18:35:03.471: ......
Read more >
ParcelFileDescriptor - Android Developers
If this ParcelFileDescriptor is unable to detect remote errors, ... the remote side is unable to communicate any errors through closeWithError(java.lang.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found