You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "kamalcph (via GitHub)" <gi...@apache.org> on 2023/09/03 13:48:55 UTC
[GitHub] [kafka] kamalcph opened a new pull request, #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
kamalcph opened a new pull request, #14329:
URL: https://github.com/apache/kafka/pull/14329
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315134679
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -379,9 +379,9 @@ public void stopPartitions(Set<TopicPartition> topicPartitions,
LOGGER.error("Error while stopping the partition: {}, delete: {}", tpId.topicPartition(), delete, ex);
}
});
- remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
if (delete) {
// NOTE: this#stopPartitions method is called when Replica state changes to Offline and ReplicaDeletionStarted
+ remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
Review Comment:
yes, you're right. When the replica is moved to another node, then the RLMM#stopPartition won't be called. We can handle this case in TBRLMM by adding a test to ensure that if the same replica is reverted back to the previous node, then it gets handled gracefully. But, we need to handle this case for any RLMM implementation.
Another way to fix this issue is that we can always invoke the `RLMM#stopPartition` when `deleteLocalLog` is set to true but that requires good amount of changes.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] divijvaidya commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315061717
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -379,9 +379,9 @@ public void stopPartitions(Set<TopicPartition> topicPartitions,
LOGGER.error("Error while stopping the partition: {}, delete: {}", tpId.topicPartition(), delete, ex);
}
});
- remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
if (delete) {
// NOTE: this#stopPartitions method is called when Replica state changes to Offline and ReplicaDeletionStarted
+ remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
Review Comment:
> Stop partition request will be called when a topic is deleted, partition is moved to another replica and node is stopped.
The 4th case in future is going to be when TS is disabled dynamically for a topic (KIP-950). In such a scenario, TBRLMM will probably still have a problem if the disablement has a "retain=delete". We can solve it in scope for KIP-950 but heads-up that some changes in TBRLMM will be required.
> In the first 2 cases, the request will have delete flag set to true.
When replica is moving to another node, why would `deleteRemoteLog` be true? Yes, the `deleteLocalLog` will be true but not `deleteRemoteLog`. Please help me understand this.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1314264907
##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerManager.java:
##########
@@ -98,35 +98,28 @@ public void waitTillConsumptionCatchesUp(RecordMetadata recordMetadata) throws T
*/
public void waitTillConsumptionCatchesUp(RecordMetadata recordMetadata,
long timeoutMs) throws TimeoutException {
- final int partition = recordMetadata.partition();
- final long consumeCheckIntervalMs = Math.min(CONSUME_RECHECK_INTERVAL_MS, timeoutMs);
-
- log.info("Waiting until consumer is caught up with the target partition: [{}]", partition);
-
+ int partition = recordMetadata.partition();
// If the current assignment does not have the subscription for this partition then return immediately.
if (!consumerTask.isMetadataPartitionAssigned(partition)) {
- throw new KafkaException("This consumer is not assigned to the target partition " + partition + ". " +
- "Partitions currently assigned: " + consumerTask.metadataPartitionsAssigned());
+ throw new KafkaException("This consumer is not assigned to the target partition " + partition +
+ ". Currently assigned partitions: " + consumerTask.metadataPartitionsAssigned());
}
-
- final long offset = recordMetadata.offset();
+ long offset = recordMetadata.offset();
long startTimeMs = time.milliseconds();
+ long consumeCheckIntervalMs = Math.min(CONSUME_RECHECK_INTERVAL_MS, timeoutMs);
+ log.info("Wait until the consumer is caught up with the target partition {} up-to offset {}", partition, offset);
while (true) {
- log.debug("Checking if partition [{}] is up to date with offset [{}]", partition, offset);
long readOffset = consumerTask.readOffsetForMetadataPartition(partition).orElse(-1L);
if (readOffset >= offset) {
return;
}
-
- log.debug("Expected offset [{}] for partition [{}], but the committed offset: [{}], Sleeping for [{}] to retry again",
- offset, partition, readOffset, consumeCheckIntervalMs);
-
+ log.debug("Expected offset for partition {} is {}, but the read offset is {}. " +
+ "Sleeping for {} ms to retry again", partition, offset, readOffset, consumeCheckIntervalMs);
if (time.milliseconds() - startTimeMs > timeoutMs) {
- log.warn("Expected offset for partition:[{}] is : [{}], but the committed offset: [{}] ",
- partition, readOffset, offset);
+ log.warn("Expected offset for partition {} is {}, but the read offset is {}",
+ partition, offset, readOffset);
throw new TimeoutException("Timed out in catching up with the expected offset by consumer.");
}
-
time.sleep(consumeCheckIntervalMs);
Review Comment:
@satishd
Updated the logs to capture most of the information which helps to debug any issue.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] satishd commented on pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #14329:
URL: https://github.com/apache/kafka/pull/14329#issuecomment-1707469208
Merging it to trunk and 3.6 to unblock as it received 3 +1s. A couple of test failures unrelated to this change. Merging it to trunk and 3.6.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] satishd merged pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd merged PR #14329:
URL: https://github.com/apache/kafka/pull/14329
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on PR #14329:
URL: https://github.com/apache/kafka/pull/14329#issuecomment-1705975965
Rebased the PR against trunk.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315134679
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -379,9 +379,9 @@ public void stopPartitions(Set<TopicPartition> topicPartitions,
LOGGER.error("Error while stopping the partition: {}, delete: {}", tpId.topicPartition(), delete, ex);
}
});
- remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
if (delete) {
// NOTE: this#stopPartitions method is called when Replica state changes to Offline and ReplicaDeletionStarted
+ remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
Review Comment:
yes, you're right. When the replica is moved to another node, then the RLMM#stopPartition won't be called. We can handle this case in TBRLMM by adding a test to ensure that if the same replica is reverted back to the previous node, then it gets handled gracefully. But, we need to handle this case for any RLMM implementation.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] divijvaidya commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315581274
##########
core/src/main/scala/kafka/server/ReplicaManager.scala:
##########
@@ -590,14 +586,9 @@ class ReplicaManager(val config: KafkaConfig,
logManager.asyncDelete(partitionsToDelete, (tp, e) => errorMap.put(tp, e))
}
remoteLogManager.foreach { rlm =>
- // exclude the partitions with offline/error state
Review Comment:
Why are we ignoring this business logic in the new revision? If you look above at the business logic of deleting the local partition, we only call delete local partition for Online partitions even if deleteLocalPartition flag is set.
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -349,41 +350,46 @@ public void onLeadershipChange(Set<Partition> partitionsBecomeLeader,
}
/**
- * Deletes the internal topic partition info if delete flag is set as true.
+ * Stop the remote-log-manager task for the given partitions. And, calls the
+ * {@link RemoteLogMetadataManager#onStopPartitions(Set)} when {@link StopPartition#deleteLocalLog()} is true.
+ * Deletes the partitions from the remote storage when {@link StopPartition#deleteRemoteLog()} is true.
*
- * @param topicPartitions topic partitions that needs to be stopped.
- * @param delete flag to indicate whether the given topic partitions to be deleted or not.
+ * @param stopPartitions topic partitions that needs to be stopped.
* @param errorHandler callback to handle any errors while stopping the partitions.
*/
- public void stopPartitions(Set<TopicPartition> topicPartitions,
- boolean delete,
+ public void stopPartitions(Set<StopPartition> stopPartitions,
BiConsumer<TopicPartition, Throwable> errorHandler) {
- LOGGER.debug("Stopping {} partitions, delete: {}", topicPartitions.size(), delete);
- Set<TopicIdPartition> topicIdPartitions = topicPartitions.stream()
- .filter(topicIdByPartitionMap::containsKey)
- .map(tp -> new TopicIdPartition(topicIdByPartitionMap.get(tp), tp))
- .collect(Collectors.toSet());
-
- topicIdPartitions.forEach(tpId -> {
+ LOGGER.debug("Stop partitions: {}", stopPartitions);
+ for (StopPartition stopPartition: stopPartitions) {
+ TopicPartition tp = stopPartition.topicPartition();
try {
- RLMTaskWithFuture task = leaderOrFollowerTasks.remove(tpId);
- if (task != null) {
- LOGGER.info("Cancelling the RLM task for tpId: {}", tpId);
- task.cancel();
- }
- if (delete) {
- LOGGER.info("Deleting the remote log segments task for partition: {}", tpId);
- deleteRemoteLogPartition(tpId);
+ if (topicIdByPartitionMap.containsKey(tp)) {
+ TopicIdPartition tpId = new TopicIdPartition(topicIdByPartitionMap.get(tp), tp);
+ RLMTaskWithFuture task = leaderOrFollowerTasks.remove(tpId);
+ if (task != null) {
+ LOGGER.info("Cancelling the RLM task for tpId: {}", tpId);
+ task.cancel();
+ }
+ if (stopPartition.deleteRemoteLog()) {
+ LOGGER.info("Deleting the remote log segments task for partition: {}", tpId);
+ deleteRemoteLogPartition(tpId);
+ }
}
Review Comment:
else please print an warn. This is not expected.
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -379,9 +379,9 @@ public void stopPartitions(Set<TopicPartition> topicPartitions,
LOGGER.error("Error while stopping the partition: {}, delete: {}", tpId.topicPartition(), delete, ex);
}
});
- remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
if (delete) {
// NOTE: this#stopPartitions method is called when Replica state changes to Offline and ReplicaDeletionStarted
+ remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
Review Comment:
> Another way to fix this issue is that we can always invoke the RLMM#stopPartition when deleteLocalLog is set to true but that requires good amount of changes.
We want to stop archival i.e. call `leaderOrFollowerTasks.remove(tpId);` even for cases when `deleteLocalLog` is not true. I understand that you handled this in current code but wanted to call this expectation out as a reply to your above comment.
Perhaps add a unit test (if missing) specifically to test that this expectation is not violated?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1314264284
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -379,9 +379,9 @@ public void stopPartitions(Set<TopicPartition> topicPartitions,
LOGGER.error("Error while stopping the partition: {}, delete: {}", tpId.topicPartition(), delete, ex);
}
});
- remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
if (delete) {
// NOTE: this#stopPartitions method is called when Replica state changes to Offline and ReplicaDeletionStarted
+ remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
Review Comment:
@divijvaidya
We need to revert this change (see this [comment](https://github.com/apache/kafka/pull/13947/files#r1294768292)). In the ZK mode, controller sends two stop-partitions request while deleting the topic when the replica state changes to `Offline` and `ReplicaDeletionStarted`.
RLMM#onStopPartitions causes the TBRLMM consumer to stop consuming records for those respective user-topic-partitions which inturn causes the segment deletion to fail for that topic (since we write a metadata record and read from that topic to denote that the metadata written successfully).
Stop partition request will be called when a topic is deleted, partition is moved to another replica and node is stopped. In the first 2 cases, the request will have `delete` flag set to true. When the node is stopped, RLMM will be closed anyway.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1314265438
##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManager.java:
##########
@@ -377,7 +377,9 @@ private void initializeResources() {
final NewTopic remoteLogMetadataTopicRequest = createRemoteLogMetadataTopicRequest();
boolean topicCreated = false;
long startTimeMs = time.milliseconds();
- try (AdminClient adminClient = AdminClient.create(rlmmConfig.commonProperties())) {
Review Comment:
If the user configures the admin client incorrectly (eg: forgot to supply `remote.log.metadata.manager.listener.name`), then the thread will die without throwing any exception/log so moved the `Admin` instance creation within the try-block.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315512346
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -379,9 +379,9 @@ public void stopPartitions(Set<TopicPartition> topicPartitions,
LOGGER.error("Error while stopping the partition: {}, delete: {}", tpId.topicPartition(), delete, ex);
}
});
- remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
if (delete) {
// NOTE: this#stopPartitions method is called when Replica state changes to Offline and ReplicaDeletionStarted
+ remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
Review Comment:
Addressed your review comments. Please take another look.
As per the Javadoc in [RemoteLogMetadataManager#onStopPartitions](https://github.com/apache/kafka/blob/trunk/storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogMetadataManager.java#L203), this method will be called when replica emigrates to a new broker and during topic deletion.
> /**
* This method is invoked only when the topic partitions are stopped on this broker. This can happen when a
* partition is emigrated to other broker or a partition is deleted.
*
* @param partitions topic partitions that have been stopped.
*/
void onStopPartitions(Set<TopicIdPartition> partitions);
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] divijvaidya commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1314961838
##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManager.java:
##########
@@ -438,10 +440,19 @@ private void initializeResources() {
lock.writeLock().unlock();
}
}
+ } finally {
+ if (adminClient != null) {
+ try {
+ adminClient.close(Duration.ofSeconds(10));
Review Comment:
Use `Utils.closeQuietly` ?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on PR #14329:
URL: https://github.com/apache/kafka/pull/14329#issuecomment-1704311904
@clolov @divijvaidya @showuon @abhijeetk88 @satishd
This PR is stacked on top of #14307 and #14328 to review the change-set separately (we can merge them if required). Please take a look when you get chance!
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1314264907
##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerManager.java:
##########
@@ -98,35 +98,28 @@ public void waitTillConsumptionCatchesUp(RecordMetadata recordMetadata) throws T
*/
public void waitTillConsumptionCatchesUp(RecordMetadata recordMetadata,
long timeoutMs) throws TimeoutException {
- final int partition = recordMetadata.partition();
- final long consumeCheckIntervalMs = Math.min(CONSUME_RECHECK_INTERVAL_MS, timeoutMs);
-
- log.info("Waiting until consumer is caught up with the target partition: [{}]", partition);
-
+ int partition = recordMetadata.partition();
// If the current assignment does not have the subscription for this partition then return immediately.
if (!consumerTask.isMetadataPartitionAssigned(partition)) {
- throw new KafkaException("This consumer is not assigned to the target partition " + partition + ". " +
- "Partitions currently assigned: " + consumerTask.metadataPartitionsAssigned());
+ throw new KafkaException("This consumer is not assigned to the target partition " + partition +
+ ". Currently assigned partitions: " + consumerTask.metadataPartitionsAssigned());
}
-
- final long offset = recordMetadata.offset();
+ long offset = recordMetadata.offset();
long startTimeMs = time.milliseconds();
+ long consumeCheckIntervalMs = Math.min(CONSUME_RECHECK_INTERVAL_MS, timeoutMs);
+ log.info("Wait until the consumer is caught up with the target partition {} up-to offset {}", partition, offset);
while (true) {
- log.debug("Checking if partition [{}] is up to date with offset [{}]", partition, offset);
long readOffset = consumerTask.readOffsetForMetadataPartition(partition).orElse(-1L);
if (readOffset >= offset) {
return;
}
-
- log.debug("Expected offset [{}] for partition [{}], but the committed offset: [{}], Sleeping for [{}] to retry again",
- offset, partition, readOffset, consumeCheckIntervalMs);
-
+ log.debug("Expected offset for partition {} is {}, but the read offset is {}. " +
+ "Sleeping for {} ms to retry again", partition, offset, readOffset, consumeCheckIntervalMs);
if (time.milliseconds() - startTimeMs > timeoutMs) {
- log.warn("Expected offset for partition:[{}] is : [{}], but the committed offset: [{}] ",
- partition, readOffset, offset);
+ log.warn("Expected offset for partition {} is {}, but the read offset is {}",
+ partition, offset, readOffset);
throw new TimeoutException("Timed out in catching up with the expected offset by consumer.");
}
-
time.sleep(consumeCheckIntervalMs);
Review Comment:
@satishd
Update the logs to capture most of the information which helps to debug any issue.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] showuon commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315851160
##########
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala:
##########
@@ -3487,8 +3487,12 @@ class ReplicaManagerTest {
assertTrue(replicaManager.logManager.getLog(tp0).isDefined)
}
if (enableRemoteStorage) {
- verify(mockRemoteLogManager, times(1))
- .stopPartitions(ArgumentMatchers.eq(Collections.singleton(tp0)), ArgumentMatchers.eq(false), any())
+ if (throwIOException) {
+ verify(mockRemoteLogManager, times(0)).stopPartitions(any(), any())
Review Comment:
Could you explain more about why we don't call `stopPartitions` when `throwIOException` now? My understanding is this should be a bug previously that we didn't filter out the error partition. Is that right?
##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManager.java:
##########
@@ -377,7 +377,9 @@ private void initializeResources() {
final NewTopic remoteLogMetadataTopicRequest = createRemoteLogMetadataTopicRequest();
boolean topicCreated = false;
long startTimeMs = time.milliseconds();
- try (AdminClient adminClient = AdminClient.create(rlmmConfig.commonProperties())) {
Review Comment:
Nice fix!
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315883355
##########
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala:
##########
@@ -3487,8 +3487,12 @@ class ReplicaManagerTest {
assertTrue(replicaManager.logManager.getLog(tp0).isDefined)
}
if (enableRemoteStorage) {
- verify(mockRemoteLogManager, times(1))
- .stopPartitions(ArgumentMatchers.eq(Collections.singleton(tp0)), ArgumentMatchers.eq(false), any())
+ if (throwIOException) {
+ verify(mockRemoteLogManager, times(0)).stopPartitions(any(), any())
Review Comment:
yes, there was a bug. Previously, we were calling the RLM#stopPartitions twice one with `delete` set as true and false. The error partition was by-passing through the second call.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1314265053
##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerTask.java:
##########
@@ -157,9 +157,10 @@ private void processConsumerRecord(ConsumerRecord<byte[], byte[]> record) {
remotePartitionMetadataEventHandler.handleRemoteLogMetadata(remoteLogMetadata);
readOffsetsByUserTopicPartition.put(remoteLogMetadata.topicIdPartition(), record.offset());
} else {
- log.debug("The event {} is skipped because it is either already processed or not assigned to this consumer", remoteLogMetadata);
+ log.trace("The event {} is skipped because it is either already processed or not assigned to this consumer",
Review Comment:
@abhijeetk88
This log statement will be chatty and prints the entire event. Reduced the logger level from `debug` to `trace`.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] satishd commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1314498306
##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerManager.java:
##########
@@ -98,35 +98,28 @@ public void waitTillConsumptionCatchesUp(RecordMetadata recordMetadata) throws T
*/
public void waitTillConsumptionCatchesUp(RecordMetadata recordMetadata,
long timeoutMs) throws TimeoutException {
- final int partition = recordMetadata.partition();
- final long consumeCheckIntervalMs = Math.min(CONSUME_RECHECK_INTERVAL_MS, timeoutMs);
-
- log.info("Waiting until consumer is caught up with the target partition: [{}]", partition);
-
+ int partition = recordMetadata.partition();
// If the current assignment does not have the subscription for this partition then return immediately.
if (!consumerTask.isMetadataPartitionAssigned(partition)) {
- throw new KafkaException("This consumer is not assigned to the target partition " + partition + ". " +
- "Partitions currently assigned: " + consumerTask.metadataPartitionsAssigned());
+ throw new KafkaException("This consumer is not assigned to the target partition " + partition +
+ ". Currently assigned partitions: " + consumerTask.metadataPartitionsAssigned());
}
-
- final long offset = recordMetadata.offset();
+ long offset = recordMetadata.offset();
long startTimeMs = time.milliseconds();
+ long consumeCheckIntervalMs = Math.min(CONSUME_RECHECK_INTERVAL_MS, timeoutMs);
+ log.info("Wait until the consumer is caught up with the target partition {} up-to offset {}", partition, offset);
while (true) {
- log.debug("Checking if partition [{}] is up to date with offset [{}]", partition, offset);
long readOffset = consumerTask.readOffsetForMetadataPartition(partition).orElse(-1L);
if (readOffset >= offset) {
return;
}
-
- log.debug("Expected offset [{}] for partition [{}], but the committed offset: [{}], Sleeping for [{}] to retry again",
- offset, partition, readOffset, consumeCheckIntervalMs);
-
+ log.debug("Expected offset for partition {} is {}, but the read offset is {}. " +
+ "Sleeping for {} ms to retry again", partition, offset, readOffset, consumeCheckIntervalMs);
if (time.milliseconds() - startTimeMs > timeoutMs) {
- log.warn("Expected offset for partition:[{}] is : [{}], but the committed offset: [{}] ",
- partition, readOffset, offset);
+ log.warn("Expected offset for partition {} is {}, but the read offset is {}",
+ partition, offset, readOffset);
Review Comment:
Good catch on the ordering of the offsets in the log.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1314264907
##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerManager.java:
##########
@@ -98,35 +98,28 @@ public void waitTillConsumptionCatchesUp(RecordMetadata recordMetadata) throws T
*/
public void waitTillConsumptionCatchesUp(RecordMetadata recordMetadata,
long timeoutMs) throws TimeoutException {
- final int partition = recordMetadata.partition();
- final long consumeCheckIntervalMs = Math.min(CONSUME_RECHECK_INTERVAL_MS, timeoutMs);
-
- log.info("Waiting until consumer is caught up with the target partition: [{}]", partition);
-
+ int partition = recordMetadata.partition();
// If the current assignment does not have the subscription for this partition then return immediately.
if (!consumerTask.isMetadataPartitionAssigned(partition)) {
- throw new KafkaException("This consumer is not assigned to the target partition " + partition + ". " +
- "Partitions currently assigned: " + consumerTask.metadataPartitionsAssigned());
+ throw new KafkaException("This consumer is not assigned to the target partition " + partition +
+ ". Currently assigned partitions: " + consumerTask.metadataPartitionsAssigned());
}
-
- final long offset = recordMetadata.offset();
+ long offset = recordMetadata.offset();
long startTimeMs = time.milliseconds();
+ long consumeCheckIntervalMs = Math.min(CONSUME_RECHECK_INTERVAL_MS, timeoutMs);
+ log.info("Wait until the consumer is caught up with the target partition {} up-to offset {}", partition, offset);
while (true) {
- log.debug("Checking if partition [{}] is up to date with offset [{}]", partition, offset);
long readOffset = consumerTask.readOffsetForMetadataPartition(partition).orElse(-1L);
if (readOffset >= offset) {
return;
}
-
- log.debug("Expected offset [{}] for partition [{}], but the committed offset: [{}], Sleeping for [{}] to retry again",
- offset, partition, readOffset, consumeCheckIntervalMs);
-
+ log.debug("Expected offset for partition {} is {}, but the read offset is {}. " +
+ "Sleeping for {} ms to retry again", partition, offset, readOffset, consumeCheckIntervalMs);
if (time.milliseconds() - startTimeMs > timeoutMs) {
- log.warn("Expected offset for partition:[{}] is : [{}], but the committed offset: [{}] ",
- partition, readOffset, offset);
+ log.warn("Expected offset for partition {} is {}, but the read offset is {}",
+ partition, offset, readOffset);
throw new TimeoutException("Timed out in catching up with the expected offset by consumer.");
}
-
time.sleep(consumeCheckIntervalMs);
Review Comment:
@satishd
Update the logs to capture most of the information while helps to debug any issue.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] showuon commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1316586591
##########
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala:
##########
@@ -3487,8 +3487,12 @@ class ReplicaManagerTest {
assertTrue(replicaManager.logManager.getLog(tp0).isDefined)
}
if (enableRemoteStorage) {
- verify(mockRemoteLogManager, times(1))
- .stopPartitions(ArgumentMatchers.eq(Collections.singleton(tp0)), ArgumentMatchers.eq(false), any())
+ if (throwIOException) {
+ verify(mockRemoteLogManager, times(0)).stopPartitions(any(), any())
Review Comment:
Good catch. Thanks.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315617486
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -349,41 +350,46 @@ public void onLeadershipChange(Set<Partition> partitionsBecomeLeader,
}
/**
- * Deletes the internal topic partition info if delete flag is set as true.
+ * Stop the remote-log-manager task for the given partitions. And, calls the
+ * {@link RemoteLogMetadataManager#onStopPartitions(Set)} when {@link StopPartition#deleteLocalLog()} is true.
+ * Deletes the partitions from the remote storage when {@link StopPartition#deleteRemoteLog()} is true.
*
- * @param topicPartitions topic partitions that needs to be stopped.
- * @param delete flag to indicate whether the given topic partitions to be deleted or not.
+ * @param stopPartitions topic partitions that needs to be stopped.
* @param errorHandler callback to handle any errors while stopping the partitions.
*/
- public void stopPartitions(Set<TopicPartition> topicPartitions,
- boolean delete,
+ public void stopPartitions(Set<StopPartition> stopPartitions,
BiConsumer<TopicPartition, Throwable> errorHandler) {
- LOGGER.debug("Stopping {} partitions, delete: {}", topicPartitions.size(), delete);
- Set<TopicIdPartition> topicIdPartitions = topicPartitions.stream()
- .filter(topicIdByPartitionMap::containsKey)
- .map(tp -> new TopicIdPartition(topicIdByPartitionMap.get(tp), tp))
- .collect(Collectors.toSet());
-
- topicIdPartitions.forEach(tpId -> {
+ LOGGER.debug("Stop partitions: {}", stopPartitions);
+ for (StopPartition stopPartition: stopPartitions) {
+ TopicPartition tp = stopPartition.topicPartition();
try {
- RLMTaskWithFuture task = leaderOrFollowerTasks.remove(tpId);
- if (task != null) {
- LOGGER.info("Cancelling the RLM task for tpId: {}", tpId);
- task.cancel();
- }
- if (delete) {
- LOGGER.info("Deleting the remote log segments task for partition: {}", tpId);
- deleteRemoteLogPartition(tpId);
+ if (topicIdByPartitionMap.containsKey(tp)) {
+ TopicIdPartition tpId = new TopicIdPartition(topicIdByPartitionMap.get(tp), tp);
+ RLMTaskWithFuture task = leaderOrFollowerTasks.remove(tpId);
+ if (task != null) {
+ LOGGER.info("Cancelling the RLM task for tpId: {}", tpId);
+ task.cancel();
+ }
+ if (stopPartition.deleteRemoteLog()) {
+ LOGGER.info("Deleting the remote log segments task for partition: {}", tpId);
+ deleteRemoteLogPartition(tpId);
+ }
}
Review Comment:
Added a WARN log initially, then removed it. The `stopPartition` call will come for all the partitions including the internal and non-tiered storage enabled topics. Is it ok to print in WARN level for those partitions?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315644355
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -379,9 +379,9 @@ public void stopPartitions(Set<TopicPartition> topicPartitions,
LOGGER.error("Error while stopping the partition: {}, delete: {}", tpId.topicPartition(), delete, ex);
}
});
- remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
if (delete) {
// NOTE: this#stopPartitions method is called when Replica state changes to Offline and ReplicaDeletionStarted
+ remoteLogMetadataManager.onStopPartitions(topicIdPartitions);
Review Comment:
Add the respective assertions in the test.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] kamalcph commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315645231
##########
core/src/main/scala/kafka/server/ReplicaManager.scala:
##########
@@ -590,14 +586,9 @@ class ReplicaManager(val config: KafkaConfig,
logManager.asyncDelete(partitionsToDelete, (tp, e) => errorMap.put(tp, e))
}
remoteLogManager.foreach { rlm =>
- // exclude the partitions with offline/error state
Review Comment:
Reverted the logic back, I was not sure whether it will be useful to filter out the partitions with error state so ignored it.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] divijvaidya commented on a diff in pull request #14329: KAFKA-15410: Delete topic integration test with LocalTieredStorage and TBRLMM (3/4)
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14329:
URL: https://github.com/apache/kafka/pull/14329#discussion_r1315675510
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -349,41 +350,46 @@ public void onLeadershipChange(Set<Partition> partitionsBecomeLeader,
}
/**
- * Deletes the internal topic partition info if delete flag is set as true.
+ * Stop the remote-log-manager task for the given partitions. And, calls the
+ * {@link RemoteLogMetadataManager#onStopPartitions(Set)} when {@link StopPartition#deleteLocalLog()} is true.
+ * Deletes the partitions from the remote storage when {@link StopPartition#deleteRemoteLog()} is true.
*
- * @param topicPartitions topic partitions that needs to be stopped.
- * @param delete flag to indicate whether the given topic partitions to be deleted or not.
+ * @param stopPartitions topic partitions that needs to be stopped.
* @param errorHandler callback to handle any errors while stopping the partitions.
*/
- public void stopPartitions(Set<TopicPartition> topicPartitions,
- boolean delete,
+ public void stopPartitions(Set<StopPartition> stopPartitions,
BiConsumer<TopicPartition, Throwable> errorHandler) {
- LOGGER.debug("Stopping {} partitions, delete: {}", topicPartitions.size(), delete);
- Set<TopicIdPartition> topicIdPartitions = topicPartitions.stream()
- .filter(topicIdByPartitionMap::containsKey)
- .map(tp -> new TopicIdPartition(topicIdByPartitionMap.get(tp), tp))
- .collect(Collectors.toSet());
-
- topicIdPartitions.forEach(tpId -> {
+ LOGGER.debug("Stop partitions: {}", stopPartitions);
+ for (StopPartition stopPartition: stopPartitions) {
+ TopicPartition tp = stopPartition.topicPartition();
try {
- RLMTaskWithFuture task = leaderOrFollowerTasks.remove(tpId);
- if (task != null) {
- LOGGER.info("Cancelling the RLM task for tpId: {}", tpId);
- task.cancel();
- }
- if (delete) {
- LOGGER.info("Deleting the remote log segments task for partition: {}", tpId);
- deleteRemoteLogPartition(tpId);
+ if (topicIdByPartitionMap.containsKey(tp)) {
+ TopicIdPartition tpId = new TopicIdPartition(topicIdByPartitionMap.get(tp), tp);
+ RLMTaskWithFuture task = leaderOrFollowerTasks.remove(tpId);
+ if (task != null) {
+ LOGGER.info("Cancelling the RLM task for tpId: {}", tpId);
+ task.cancel();
+ }
+ if (stopPartition.deleteRemoteLog()) {
+ LOGGER.info("Deleting the remote log segments task for partition: {}", tpId);
+ deleteRemoteLogPartition(tpId);
+ }
}
Review Comment:
good point. So we are assuming that if a topic is in `topicIdByPartitionMap` then it has active archival otherwise not. This is not a good source of truth IMO since we are going to replace it with metadata cache in another PR (why have two caches for tp <-> tpId mapping).
Nevertheless, let's add a comment for now here and maybe create an improvement JIRA to not call stopPArtitions for internal or non-tiered topics.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org