Chronicle Queue despite rolling cycle minutely deleting chronicle file after processing keeps file in open list lsof and not releasing memory

Viewed 84

I am using chronicle queue version 5.20.123 and open JDK 11 with Linux Ubuntu 20.04, when we recycle current cycle on minute rolling I am listening on StoreFileListener onReleased I am deleting file then also file remains open without releasing memory nor file gets deleted..
Please guide what needs to be done in order to make it work.

Store FileListener Implemented like this:

storeFileListener = new StoreFileListener() {
                    @Override
                    public void onReleased(int cycle, File file) {
                        file.delete();
                    }
                }

Creation of chronicle Queue as follows:

eventStore = SingleChronicleQueueBuilder.binary(GlobalConstants.CURRENT_DIR
              + GlobalConstants.PATH_SEPARATOR + EventBusConstants.EVENT_DIR
              + GlobalConstants.PATH_SEPARATOR + eventType)
             .rollCycle(RollCycles.MINUTELY)
             .storeFileListener(storeFileListener).build();
tailer = eventStore.createTailer();
appender = eventStore.acquireAppender();
previousCycle = tailer.cycle();

Recycling of previous Cycle when processing completes:

var store = eventStore.storeForCycle(previousCycle,0,false,null);
eventStore.closeStore(store);

Chronicle Queue Deleted Files lsof :

enter image description here

1 Answers

Manually getting hold of store and trying to close it will do nothing but interfere with reference counting - you increase and then decrease number of references.

Chronicle Queue will automatically release resources for given store after all appenders and tailers using that store are done with it. In your case it's unclear what you do with your tailer, but if it already reads from the new file - the old one will be released, and resources associated with it - although this is done in the background and might not happen immediately.

PS file.delete() returns boolean and it's always a good idea to check the return value to see if the delete was successful (in your case it can be seen it was but still it's considered a good practice)

Related