-
Notifications
You must be signed in to change notification settings - Fork 14k
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-17850: fix leaking internal exception in state manager #17711
base: trunk
Are you sure you want to change the base?
Changes from 1 commit
db8b733
5bc70bf
5381abe
4e0ff72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import org.apache.kafka.streams.errors.StreamsException; | ||
import org.apache.kafka.streams.errors.TaskCorruptedException; | ||
import org.apache.kafka.streams.errors.TaskMigratedException; | ||
import org.apache.kafka.streams.errors.internals.FailedProcessingException; | ||
import org.apache.kafka.streams.processor.CommitCallback; | ||
import org.apache.kafka.streams.processor.StateRestoreCallback; | ||
import org.apache.kafka.streams.processor.StateRestoreListener; | ||
|
@@ -538,13 +539,16 @@ public void flush() { | |
} catch (final RuntimeException exception) { | ||
if (firstException == null) { | ||
// do NOT wrap the error if it is actually caused by Streams itself | ||
if (exception instanceof StreamsException) | ||
// In case of FailedProcessingException Do not keep the failed processing exception in the stack trace | ||
if (exception instanceof FailedProcessingException) | ||
firstException = new StreamsException(exception.getCause()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before we introduced the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case of FailedProcessingException, wrap it into a ProcessorStateException
|
||
else if (exception instanceof StreamsException) | ||
firstException = exception; | ||
else | ||
firstException = new ProcessorStateException( | ||
format("%sFailed to flush state store %s", logPrefix, store.name()), exception); | ||
} | ||
log.error("Failed to flush state store {}: ", store.name(), exception); | ||
log.error("Failed to flush state store {}: ", store.name(), exception.getCause()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change this? If a log.error("Failed to flush state store {}: ", store.name(), exception instanceof FailedProcessingException ? exception.getCause() : exception); or maybe it is cleaner to copy the log message inside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied the log.error in the |
||
} | ||
} | ||
} | ||
|
@@ -573,7 +577,10 @@ public void flushCache() { | |
} catch (final RuntimeException exception) { | ||
if (firstException == null) { | ||
// do NOT wrap the error if it is actually caused by Streams itself | ||
if (exception instanceof StreamsException) { | ||
// In case of FailedProcessingException Do not keep the failed processing exception in the stack trace | ||
if (exception instanceof FailedProcessingException) { | ||
firstException = new StreamsException(exception.getCause()); | ||
} else if (exception instanceof StreamsException) { | ||
firstException = exception; | ||
} else { | ||
firstException = new ProcessorStateException( | ||
|
@@ -582,7 +589,7 @@ public void flushCache() { | |
); | ||
} | ||
} | ||
log.error("Failed to flush cache of store {}: ", store.name(), exception); | ||
log.error("Failed to flush cache of store {}: ", store.name(), exception.getCause()); | ||
} | ||
} | ||
} | ||
|
@@ -618,13 +625,16 @@ public void close() throws ProcessorStateException { | |
} catch (final RuntimeException exception) { | ||
if (firstException == null) { | ||
// do NOT wrap the error if it is actually caused by Streams itself | ||
if (exception instanceof StreamsException) | ||
// In case of FailedProcessingException Do not keep the failed processing exception in the stack trace | ||
if (exception instanceof FailedProcessingException) | ||
firstException = new StreamsException(exception.getCause()); | ||
else if (exception instanceof StreamsException) | ||
firstException = exception; | ||
else | ||
firstException = new ProcessorStateException( | ||
format("%sFailed to close state store %s", logPrefix, store.name()), exception); | ||
} | ||
log.error("Failed to close state store {}: ", store.name(), exception); | ||
log.error("Failed to close state store {}: ", store.name(), exception.getCause()); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add unit tests to
ProcessorStateManagerTest
that verify the correct behavior?You should also verify the behavior when a processing error handler that continues instead of fails is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added tests for flush and close in ProcessorStateManagerTest
For flushCache I added tests in ProcessingExceptionHandlerIntegrationTest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why could you not also add a test for
flushCache()
to the unit tests?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
good catch, I was not able to call flushCache() from the actual MockKeyValueStore.
So i added a new MockCacheKeyValueStore that also implements the CachedStateStore