"idleFuture" should reset to "null" after idle bucket closed
If we use "idleTimeout" to roll file, once the flush() method called, it will start a delayed thread to close the idle bucketWriter. The delayed thread will call close() method to check whether the "idleFuture" is done, and close opened file. If the "idleFuture" is running when checking, the idleFuture.isDone() method will return false, and the idleFuture won't be set to "null". When the bucketWriter calls flush() on the next time, the "idleFuture" is not "null" and idleFutrue.cancel(false) method returns false due to the "idleFuture" has completed in the last call. So new thread won't be created to close current idle bucketWriter and keeps current file openning.
Hi @hangc0276, Thank you for your patch.
Unless I misunderstood your explanation I think it can't happen. Let me summarize it, and please correct me if I got it wrong:
-
flush()schedules theidleFuture - in
close()ifidleFuture != null && !idleFuture.isDone()-> cancellingidleFutureand setting tonullBut this is a not done check, so if it's not done yet, it will be set tonull(regardless if it's currently running, which means that theclose()was called by it)
In fact the idleFuture will be set to null for sure:
- if in the previously mentioned check
idleFuture.isDone()istruethat would mean that it had been run before -> called theclose()method -> set theBucketWriter.idleFuturetonull. - if it's not done yet -> the
BucketWriter.idleFuturewill be set tonull
Let me know if you see any flaw in my reasoning.
Can one of the admins verify this patch?