0

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

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
sam
  • 2,469
  • 8
  • 37
  • 57
  • Can you include the entire stack trace as this error doesn't appear anywhere in chronicle? – Peter Lawrey Dec 23 '16 at 11:37
  • I added the stacktrace. You can see this exception thrown in line 665 of SiongleChronicleQueue class. The method toKey throws this exception. – sam Dec 23 '16 at 12:39
  • I see, you are running an older version which is why the message is different. Can you try version 4.5.19 as I can see this code has changed since that version? – Peter Lawrey Dec 23 '16 at 12:59
  • Hi, sorry 4.5.15 is the latest available to me right now where I am working. It is a fairly long process to get updates on-boarded. Do you know if the updated version fixed anything related to this? – sam Dec 23 '16 at 13:23

2 Answers2

0

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 ?

  • Ok - Could you adapt my test case above ( using the latest version of chronicle-queue ) so that it reproduced your issue and I will then fix it, if there is a problem. – Rob Austin Dec 30 '16 at 09:01
0

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));
}
Rob Austin
  • 620
  • 3
  • 5
  • Hi rob, that test case passes on my version too. As a work around for now I will store both the start and end index in a persistent map and then pass them into countExcerpts when necessary. – sam Jan 03 '17 at 10:02
  • Yep that should work. Later - if do find a way to reproduce this issue, we'd very much welcome your test case, thanks. – Rob Austin Jan 04 '17 at 18:59