Tailer synchronization after rolling

67 views
Skip to first unread message

Mickael Marrache

unread,
May 8, 2016, 6:28:52 AM5/8/16
to Chronicle
Hi,

I have multiple threads concurrently appending to the same queue. Every thread appends according to the following code snippet:

ExcerptAppender appender = queue.createAppender();
appender
.writeMap(msg.toMap());
appender
.close();


As you can see, every time a thread needs to write a message, it creates an appender (which is stored in thread local), writes the message an closes the appender (I'm not sure if it's needed to close the appender after each write?)

Also, I have one tailer created by a separate application as follows:

ExcerptTailer reader = queue.createTailer();

Map<String, Object> msg;
while(running) {
       
while((msg = reader.readMap()) != null) {
           
//Add the message to some list for later processing
       
}

       
//Process the bulk of messages that have just been read
}

reader.close();

Note that the tailer is kept open until the application is stopped.

Using the following code, I see that my tailer doesn't always synchronize with the cycles. I got multiple times in the situation where the tailer stays on the same cycle while the appenders continuously appends to new files (new cycles).

Any idea?

Thanks,
Mickael

Mickael Marrache

unread,
May 8, 2016, 7:20:49 AM5/8/16
to Chronicle
I forgot to mention that I use Chronicle Queue v4.3.2.

Peter Lawrey

unread,
May 8, 2016, 9:25:09 AM5/8/16
to java-ch...@googlegroups.com
Could you provide a unit test which demonstrates this. We have a test where this passes, but we are probably doing something different.

--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mickael Marrache

unread,
May 8, 2016, 9:43:03 AM5/8/16
to Chronicle
I made an additional test where my consumer and producers applications runs concurrently without debug.

The producer app writes a map message every 5 seconds and the rolling is configured to be minutely.

I can see the files rolling. On the other hand, the consumer app is able to process messages correctly moving between one cycle to the next.

However, when I do this kind of execution in debug mode using my IDE, I get into the case where the tailer is stuck and the readMap() method continuously returns null.

I will try to write a unit test that reproduces the issue.

Peter Lawrey

unread,
May 8, 2016, 10:08:51 AM5/8/16
to java-ch...@googlegroups.com
We have had problems in the past where the debugger interferes with the running of the problem.  This is still a bug, though it is likely to have a different cause.

Mickael Marrache

unread,
May 8, 2016, 10:13:56 AM5/8/16
to Chronicle
Here is the test you can use:

public class ChronicleRollingIssueTest {

 
@Test
 
public void test() throws Exception {
     
final ChronicleQueue writeQueue = ChronicleQueueBuilder
       
.single("your-path")
       
.rollCycle(RollCycles.MINUTELY).build();
 
     
final ChronicleQueue readQueue = ChronicleQueueBuilder
       
.single("your-path")
       
.rollCycle(RollCycles.MINUTELY).build();
 
     
Runnable appendRunnable = new Runnable() {
         
@Override
         
public void run() {
             
ExcerptAppender appender = writeQueue.createAppender();
             
Map<String, Object> map = new HashMap<String, Object>();
             map
.put("k1", "v1");
             appender
.writeMap(map);
             appender
.close();
         
}
     
};
 
     
new Thread(appendRunnable, "appender t1").start();
     
Thread.sleep(3000);
     
new Thread(appendRunnable, "appender t2").start();
     
Thread.sleep(3000);
 
     
ExcerptTailer tailer = readQueue.createTailer();
 
     
Map<String, Object> map;
     
while(!Thread.currentThread().isInterrupted()) {
       
while((map = tailer.readMap()) != null) {
           
//The test enters here for every written message until rolling is performed where readMap() continuously returns null
           
System.out.println("We just read a map");
       
}
       
       
new Thread(appendRunnable, "appender ti").start();
       
Thread.sleep(3000);
     
}
 
     tailer
.close();
 
}
}

I've tried running the test multiple times and I'm able to reproduce the issue.


Le dimanche 8 mai 2016 16:25:09 UTC+3, Peter Lawrey a écrit :

Mickael Marrache

unread,
May 8, 2016, 10:21:54 AM5/8/16
to Chronicle
I also tried running the test from the IDE without debug mode, and I still get the same issue. I don't think it's related to the debugger.

Peter Lawrey

unread,
May 8, 2016, 1:17:41 PM5/8/16
to java-ch...@googlegroups.com
Ok, Thank you. I will look into it tomorrow.

Mickael Marrache

unread,
May 11, 2016, 7:36:02 AM5/11/16
to Chronicle
I can add that I deployed my app on a Linux server (CentOS 6.7) and I didn't encounter this issue until now.

It may be a Windows related issue... I will perform more testing and let you know.

Peter Lawrey

unread,
May 11, 2016, 8:08:28 AM5/11/16
to java-ch...@googlegroups.com
Even though I believe it's windows related, we should still fix it.

Mickael Marrache

unread,
May 11, 2016, 8:09:58 AM5/11/16
to java-ch...@googlegroups.com
I agree. I just intended to provide you more information hoping it will be easier for you to find the issue :)

Peter Lawrey

unread,
May 11, 2016, 8:14:24 AM5/11/16
to java-ch...@googlegroups.com
We really appreciate the feedback. :)

Peter Lawrey

unread,
May 12, 2016, 2:34:16 AM5/12/16
to java-ch...@googlegroups.com
Hello Mickael,

The API was broken as you shouldn't be able to close() on the Appender or Tailer (but you could) So I am restructuring the API so you can't call it this way.  I have rewritten the test for 64 threads and SECONDLY updates and I am testing it now.  I have a couple of meetings but I hope to fix it today.

I have added a test, which is showing a different problem occasionally on start up. 

Regards,
   Peter.
Reply all
Reply to author
Forward
0 new messages