swamirishi commented on code in PR #9423:
URL: https://github.com/apache/ozone/pull/9423#discussion_r2616455005
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/DeleteKeysResult.java:
##########
@@ -27,12 +30,35 @@
public class DeleteKeysResult {
private List<OmKeyInfo> keysToDelete;
-
private boolean processedKeys;
+ private List<ExclusiveRange> keyRanges;
+ private static final Logger LOG =
LoggerFactory.getLogger(DeleteKeysResult.class);
- public DeleteKeysResult(List<OmKeyInfo> keysToDelete, boolean processedKeys)
{
+ public DeleteKeysResult(List<OmKeyInfo> keysToDelete, List<ExclusiveRange>
keyRanges, boolean processedKeys) {
this.keysToDelete = keysToDelete;
this.processedKeys = processedKeys;
+ this.keyRanges = keyRanges;
+ validateNonOverlappingRanges();
+ }
+
+ private void validateNonOverlappingRanges() {
+ if (keyRanges == null || keyRanges.size() <= 1) {
+ return;
+ }
+ String lastEnd = null;
+ for (ExclusiveRange range : keyRanges) {
+ if (range == null || range.getStartKey() == null ||
range.getExclusiveEndKey() == null) {
+ continue;
+ }
+ if (lastEnd != null && range.getStartKey().compareTo(lastEnd) < 0) {
+ LOG.warn(
+ "Overlapping or unsorted delete ranges detected. " + "Clearing
keyRanges to avoid incorrect deleteRange. " +
+ "previousEnd={}, currentStart={}", lastEnd,
range.getStartKey());
+ keyRanges = Collections.emptyList();
Review Comment:
Please write a unit test for this. The CI should have failed ideally for
such bugs it just points that we don't have a unit test for this case.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]