Chronicle 'file not found' for file in the future

205 views Asked by At

I am using Chronicle Queue v4.5.15. I have created a method to tell me the number of elements that are in the queue:

public long getQueueSize() {
  long index = getQueueIndex(); // I store the index in a persistent map so this method simply retrieves the current index from the map.

  ExcerptTailer tailer = queue.createTailer();

  long lastIndex = tailer.toEnd().index(); // Get the last index in our queue.
  long count = queue.countExcerpts(queueIndex, lastIndex);

  return count

}

I ran a test overnight and my component had a cq4 queue file written for the 22nd of December. It is on a daily cycle. I tried adding some elements to the queue today and there is an exception thrown 'IllegalStateException: 'file not found' for the upperCycle, file ../path_to_queue/20161314.cq4.

Stacktrace:

Caused by java.lang.IllegalStateException: java.lang.IllegalStateException: 'file not found' for the upperCycle, file=/var/tmp/app/20161224.cq4
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueue.countExcertps(SingleChronicleQueue.java:359(
at ...

Seeing as its the 23rd of December today, why is Chronicle looking for a file in the future?

Could it be something to do with the way I get the last index?

Thanks

2

There are 2 answers

2
Rob Austin On

Could you retest with the last version - I've added the following test case, which passes.

see: RollingChronicleQueueTest

@Test
public void testCountExcerptsWhenTheCycleIsRolled() throws Exception {

    final AtomicLong time = new AtomicLong();

    final SingleChronicleQueue q = binary(getTmpDir())
            .timeProvider(time::get)
            .rollCycle(TEST_SECONDLY)
            .build();

    final ExcerptAppender appender = q.acquireAppender();
    time.set(0);

    appender.writeText("1. some  text");
    long start = appender.lastIndexAppended();
    appender.writeText("2. some more text");
    time.set(1000);
    appender.writeText("3. some text - first cycle");
    time.set(2000);
    time.set(3000); // large gap to miss a cycle file
    time.set(4000);
    appender.writeText("4. some text - second cycle");
    appender.writeText("some more text");
    long end = appender.lastIndexAppended();

    Assert.assertEquals(4, q.countExcerpts(start, end));
}
1
Gürtuğ Güngör On

maybe it's all about the day counter variable, i mean when you add some elements code could count it for day cycle and change the day to one day after. Did you try to add elements many times ? if you did what happened ?