Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-6259: Make KafkaStreams.cleanup() clean global state directory #4255

Closed
wants to merge 4 commits into from

Conversation

mjsax
Copy link
Member

@mjsax mjsax commented Nov 22, 2017

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@mjsax
Copy link
Member Author

mjsax commented Nov 22, 2017

Call for review @bbejeck @guozhangwang @dguy

Guess, we can merge this to 1.0. and 0.11.0, too?

@dguy
Copy link
Contributor

dguy commented Nov 23, 2017

retest this please

1 similar comment
@guozhangwang
Copy link
Contributor

retest this please

@guozhangwang
Copy link
Contributor

:streams:findbugsMain FAILED is this related?

@mjsax
Copy link
Member Author

mjsax commented Nov 27, 2017

Updated this.

Copy link
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, otherwise LGTM.

cleanRemovedTasks(cleanupDelayMs, true);
} catch (final IOException cannotHappen) {
// dummy log to make findbugs happy
log.error("{} Failed to delete the state directory due to an unexpected exception.", logPrefix(), cannotHappen);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we throw an IllegalStateException instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set swallowException=true -- wouldn't throwing an exception contradict this? Note, this code path is used for the task cleaner back ground thread -- an exception would kill this thread, what is the reason why I we want to swallow. Or do I miss anything?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing IllegalStateException is served as the purpose that "this should never happen, and if it does it is a bug and hence it is ok to fail and stop the world".

Copy link
Member Author

@mjsax mjsax Nov 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Fine with me.

// this is already logged within cleanRemovedTasks
firstException = new StreamsException(e);
}
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still continue deleting the global state directory if the local task directories cleanup failed? I'm thinking if the local stores deletion fails while global store succeeded, we will throw an exception, and user may retry in which case globalStateDir() will be called and trying to re-create the folder and delete it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also "keep going" of cleaning a task directory fails (ie, don't stop on first error). Thus, it's a consistent pattern. We could of course change this via a "failFast" flag for cleanRemovedTasks. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference is that in cleanRemovedTasks() (originally we do not throw exception) we do not return a boolean or throwing exception indicating if it completely succeeds or not. So this call itself is effectively "best effort" but we do not comment it probably since it is an internal function. Now as we change it to throw exception if parameterized so I'm just wondering if we should still make this behavior.

Anyways, it is just a wild thought but not really a suggested comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just about code sharing. If we call it internally, we can keep "best effort" approach. If users calls it, we can apply fail-fast IMHO. Will update the code.

@mjsax
Copy link
Member Author

mjsax commented Nov 27, 2017

Updated this.

@dguy
Copy link
Contributor

dguy commented Nov 28, 2017

retest this please

@guozhangwang
Copy link
Contributor

checkstyle error:

:streams:checkstyleMain[ant:checkstyle] [ERROR] /home/jenkins/jenkins-slave/workspace/kafka-pr-jdk7-scala2.11/streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java:231: 'catch' child have incorrect indentation level 11, expected level should be 12. [Indentation]

@mjsax
Copy link
Member Author

mjsax commented Nov 29, 2017

Updates this. Jenkins did not startup properly.

Retest this please.

@dguy
Copy link
Contributor

dguy commented Nov 29, 2017

retest this please

1 similar comment
@bbejeck
Copy link
Contributor

bbejeck commented Nov 29, 2017

retest this please

final long now = time.milliseconds();
final long lastModifiedMs = taskDir.lastModified();
if (now > lastModifiedMs + cleanupDelayMs || manualUserCall) {
if (!manualUserCall) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe always log the deletion of the state directory, but modify the message if it's from time expiring vs. a manualUserCall?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this when merging.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbejeck
Copy link
Contributor

bbejeck commented Nov 29, 2017

@mjsax a little late in reviewing, just one minor comment but otherwise LGTM

@guozhangwang
Copy link
Contributor

LGTM. Merged to trunk.

@asfgit asfgit closed this in b512cd4 Nov 29, 2017
@mjsax mjsax deleted the kafka-6259-clean-global-state-dir branch November 29, 2017 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants