kamalcph commented on code in PR #16959: URL: https://github.com/apache/kafka/pull/16959#discussion_r1732078600
########## core/src/main/java/kafka/log/remote/RemoteLogManager.java: ########## @@ -951,7 +951,18 @@ private void copyLogSegment(UnifiedLog log, LogSegment segment, RemoteLogSegment producerStateSnapshotFile.toPath(), leaderEpochsIndex); brokerTopicStats.topicStats(log.topicPartition().topic()).remoteCopyRequestRate().mark(); brokerTopicStats.allTopicsStats().remoteCopyRequestRate().mark(); - Optional<CustomMetadata> customMetadata = remoteLogStorageManager.copyLogSegmentData(copySegmentStartedRlsm, segmentData); + Optional<CustomMetadata> customMetadata = Optional.empty(); + try { + customMetadata = remoteLogStorageManager.copyLogSegmentData(copySegmentStartedRlsm, segmentData); + } catch (RemoteStorageException e) { + try { + remoteLogStorageManager.deleteLogSegmentData(copySegmentStartedRlsm); + logger.info("Successfully cleaned segment after failing to copy segment"); Review Comment: nit: Can we also log the segment-id? ########## core/src/main/java/kafka/log/remote/RemoteLogManager.java: ########## @@ -951,7 +951,18 @@ private void copyLogSegment(UnifiedLog log, LogSegment segment, RemoteLogSegment producerStateSnapshotFile.toPath(), leaderEpochsIndex); brokerTopicStats.topicStats(log.topicPartition().topic()).remoteCopyRequestRate().mark(); brokerTopicStats.allTopicsStats().remoteCopyRequestRate().mark(); - Optional<CustomMetadata> customMetadata = remoteLogStorageManager.copyLogSegmentData(copySegmentStartedRlsm, segmentData); + Optional<CustomMetadata> customMetadata = Optional.empty(); + try { + customMetadata = remoteLogStorageManager.copyLogSegmentData(copySegmentStartedRlsm, segmentData); + } catch (RemoteStorageException e) { + try { + remoteLogStorageManager.deleteLogSegmentData(copySegmentStartedRlsm); + logger.info("Successfully cleaned segment after failing to copy segment"); + } catch (RemoteStorageException e1) { + logger.error("Error while cleaning segment, consider cleaning manually", e1); Review Comment: nit: can we also log the segment-id? -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org