Copilot commented on code in PR #24310:
URL: https://github.com/apache/kafka/pull/24310#discussion_r4647652122
##########
streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java:
##########
@@ -376,8 +378,28 @@ public List<PartitionInfo> partitionsFor(final String
topic) {
logContext
);
- setupGlobalTask(mockWallClockTime, streamsConfig, streamsMetrics,
cache);
- setupTask(streamsConfig, streamsMetrics, cache,
internalTopologyBuilder.topologyConfigs().getTaskConfig());
+ try {
+ setupGlobalTask(mockWallClockTime, streamsConfig, streamsMetrics,
cache);
+ setupTask(streamsConfig, streamsMetrics, cache,
internalTopologyBuilder.topologyConfigs().getTaskConfig());
+ } catch (final Throwable e) {
+ // the caller gets no driver to close
+ Utils.closeQuietly(() -> closeDirty(e instanceof
TaskCorruptedException), "topology test driver");
+ throw e;
+ }
+ }
+
+ private void closeDirty(final boolean corrupted) throws IOException {
+ if (task != null) {
+ task.suspend();
+ if (corrupted) {
+ // as for a corrupted task in Kafka Streams, so that its state
is wiped with transactional state stores too
+ task.markChangelogAsCorrupted(task.changelogPartitions());
Review Comment:
If the first or only store throws `TaskCorruptedException` before
registering, this marks an empty changelog set. With exactly-once and
transactional state stores enabled, `hasCorruptedStores()` remains false and
dirty close preserves the corrupted task directory, so another construction can
fail on the same state. Track task corruption independently of registered
stores and add a regression with a pre-existing task directory whose first
store fails.
##########
streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java:
##########
@@ -376,8 +378,28 @@ public List<PartitionInfo> partitionsFor(final String
topic) {
logContext
);
- setupGlobalTask(mockWallClockTime, streamsConfig, streamsMetrics,
cache);
- setupTask(streamsConfig, streamsMetrics, cache,
internalTopologyBuilder.topologyConfigs().getTaskConfig());
+ try {
+ setupGlobalTask(mockWallClockTime, streamsConfig, streamsMetrics,
cache);
+ setupTask(streamsConfig, streamsMetrics, cache,
internalTopologyBuilder.topologyConfigs().getTaskConfig());
+ } catch (final Throwable e) {
+ // the caller gets no driver to close
+ Utils.closeQuietly(() -> closeDirty(e instanceof
TaskCorruptedException), "topology test driver");
Review Comment:
This cleanup cannot close a store that fails before registering:
`RocksDBStore.init()` opens the database and then reads the legacy
`<store>.position` file before registration. If that read throws, neither state
manager closes the unregistered store, so its RocksDB resources remain open
after construction fails. Close partially initialized stores on their
initialization failure path, and add a regression for a malformed position file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]