Skip to content

"idleFuture" should reset to "null" after idle bucket closed - #114

Open
hangc0276 wants to merge 1 commit into
apache:trunkfrom
hangc0276:trunk
Open

"idleFuture" should reset to "null" after idle bucket closed#114
hangc0276 wants to merge 1 commit into
apache:trunkfrom
hangc0276:trunk

Conversation

@hangc0276

Copy link
Copy Markdown

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.

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.
@adenes

adenes commented Mar 9, 2017

Copy link
Copy Markdown
Contributor

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 the idleFuture
  • in close() if idleFuture != null && !idleFuture.isDone() -> cancelling idleFuture and setting to null
    But this is a not done check, so if it's not done yet, it will be set to null (regardless if it's currently running, which means that the close() was called by it)

In fact the idleFuture will be set to null for sure:

  • if in the previously mentioned check idleFuture.isDone() is true that would mean that it had been run before -> called the close() method -> set the BucketWriter.idleFuture to null.
  • if it's not done yet -> the BucketWriter.idleFuture will be set to null

Let me know if you see any flaw in my reasoning.

@asfgit

asfgit commented Aug 17, 2018

Copy link
Copy Markdown

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants