Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed StoreTailer.toEnd() returning NOT_REACHED when called as the queue rolled #702

Closed
RobAustin opened this issue Aug 13, 2020 · 2 comments
Assignees

Comments

@RobAustin
Copy link
Member

RobAustin commented Aug 13, 2020

The following exception was found by a client

java.lang.IllegalStateException: NOT_REACHED index: 6c52300000000
at net.openhft.chronicle.queue.impl.single.StoreTailer.originalToEnd(StoreTailer.java:866)
at net.openhft.chronicle.queue.impl.single.StoreTailer.toEnd(StoreTailer.java:761)
at XXX.chronicle.queue.EventQueueForwarder.readWriteBytes(EventQueueForwarder.java:145)
at XXX.chronicle.queue.EventQueueForwarder.lambda$startWriteBytes$1(EventQueueForwarder.java:114)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at net.openhft.chronicle.core.threads.CleaningThread.run(CleaningThread.java:38)

The loop where this is thrown looks like:

while (running) {
    final long endIndex = assertionTailer.toEnd().index(); // Exception thrown here
    try (DocumentContext inDC = readTailer.readingDocument()) {
        if (inDC.isPresent()) {
            // Do something
        } else {
            // Verify that the assertion tailer index == readTailer.index()
        }
    }
}

This happened at 7pm on the dot last night - we roll the files hourly so could this have had something to do with it?

@RobAustin RobAustin self-assigned this Aug 13, 2020
@RobAustin
Copy link
Member Author

I wrote the following test case

package net.openhft.chronicle;

import net.openhft.chronicle.core.time.TimeProvider;
import net.openhft.chronicle.queue.ChronicleQueueTestBase;
import net.openhft.chronicle.queue.ExcerptAppender;
import net.openhft.chronicle.queue.ExcerptTailer;
import net.openhft.chronicle.queue.RollCycles;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueue;
import org.junit.Test;

import java.util.concurrent.Executors;
import java.util.concurrent.locks.LockSupport;

import static net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder.binary;

public class TestCallingToEndOnRoll extends ChronicleQueueTestBase implements TimeProvider {

    private long currentTime = 0;
    private ExcerptAppender appender;
    private ExcerptTailer tailer;

    @Test
    public void test() {
        SingleChronicleQueue build = binary(getTmpDir()).rollCycle(RollCycles.TEST_SECONDLY).timeProvider(this).build();
        appender = build.acquireAppender();

        tailer = build.createTailer();
        Executors.newSingleThreadExecutor().submit(this::append);

       // Executors.newSingleThreadExecutor().submit(this::toEnd);
        //
        LockSupport.park();
    }

    private void append() {
        for (; ; ) {
         toEnd0();
            appender.writeText("hello world");
            toEnd0();
        }

    }

    private void toEnd() {
        for (; ; ) {
            toEnd0();
        }
    }

    private void toEnd0() {
        try {
            long index = tailer.toEnd().index();
            System.out.println("index = " + index);
        } catch (IllegalStateException e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    @Override
    public long currentTimeMillis() {
        return (currentTime = currentTime + 1000);
    }
}

and was able to reproduce this issue after running it for 38 mins

@hft-team-city
Copy link
Collaborator

Released in Chronicle-Queue-5.20.4, BOM-2.20.22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants