This is an automated email from the ASF dual-hosted git repository.

ChenSammi pushed a commit to branch revert-12032-HDDS-17769
in repository https://gitbox.apache.org/repos/asf/ozone.git

commit ebe909deb4f9ed61a0f29c46e969363cee6fa773
Author: Sammi Chen <[email protected]>
AuthorDate: Mon Nov 16 20:10:11 2026 +0800

    Revert "HDDS-17769. Allow bucket scan continue if 
ozone.lifecycle.service.del…"
    
    This reverts commit 0fdf8da5171b60fa32db67f13d96eb1512f97291.
---
 .../ozone/om/service/KeyLifecycleService.java      |  28 ++----
 .../om/service/KeyLifecycleServiceConfig.java      |   4 +-
 .../ozone/om/service/TestKeyLifecycleService.java  | 104 ++-------------------
 3 files changed, 14 insertions(+), 122 deletions(-)

diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleService.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleService.java
index b042b9675ab..efcd54b4e7a 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleService.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleService.java
@@ -320,7 +320,6 @@ public final class LifecycleActionTask implements 
BackgroundTask {
     private long lastStateSaveTime = Time.monotonicNow();
     private long lastStateSaveKeyCount = 0;
     private boolean scanAborted;
-    private long stackCapacitySkippedDirectories = 0;
 
     private boolean shouldSaveState() {
       if ((Time.monotonicNow() - lastStateSaveTime) > stateSaveIntervalMs ||
@@ -681,7 +680,7 @@ private void evaluateKeyAndDirTable(OmBucketInfo bucket, 
long volumeObjId, Table
           stack.push(new PendingEvaluateDirectory(null, "", "", null));
         }
       } catch (CapacityFullException e) {
-        stackCapacitySkippedDirectories++;
+        LOG.warn("Abort evaluate {}/{} at {}", volumeName, bucketName, 
directoryPath != null ? directoryPath : "", e);
         return;
       }
 
@@ -795,8 +794,8 @@ private void evaluateKeyAndDirTable(OmBucketInfo bucket, 
long volumeObjId, Table
             try {
               stack.push(item);
             } catch (CapacityFullException e) {
-              stackCapacitySkippedDirectories++;
-              continue;
+              LOG.warn("Abort evaluate {}/{} at {}", volumeName, bucketName, 
currentDirPath, e);
+              return;
             }
 
             // depth first evaluation, push subDirs into stack
@@ -808,10 +807,8 @@ private void evaluateKeyAndDirTable(OmBucketInfo bucket, 
long volumeObjId, Table
                 stack.push(new PendingEvaluateDirectory(subDir, 
subDirSummary.getSubDirKeyList().get(i),
                     subDirPath, null));
               } catch (CapacityFullException e) {
-                // The stack stays full until an entry is popped, so the 
remaining siblings cannot be pushed either.
-                // Skipped sub directories are not expired, which also keeps 
their parent from being expired.
-                stackCapacitySkippedDirectories += 
subDirSummary.getSubDirCount() - i;
-                break;
+                LOG.warn("Abort evaluate {}/{} at {}", volumeName, bucketName, 
subDirPath, e);
+                return;
               }
             }
             newSubDirPushed = true;
@@ -1372,10 +1369,6 @@ private void onFailure(String bucketName) {
               "aborted {} multipart uploads", timeSpent, bucketName, 
numKeyIterated,
           numDirIterated, numMultipartUploadIterated, numKeyDeleted, 
sizeKeyDeleted, numDirDeleted,
           numKeyRenamed, sizeKeyRenamed, numDirRenamed, 
numMultipartUploadAborted);
-      if (stackCapacitySkippedDirectories > 0) {
-        LOG.info("Lifecycle evaluate for {} skipped {} directories because 
in-memory directory stack "
-            + "exceeded limit {}", bucketName, 
stackCapacitySkippedDirectories, cachedDirMaxCount);
-      }
     }
 
     private void onSuccess(String bucketName) {
@@ -1392,10 +1385,6 @@ private void onSuccess(String bucketName) {
               "aborted {} multipart uploads", timeSpent, bucketName, 
numKeyIterated,
           numDirIterated, numMultipartUploadIterated, numKeyDeleted, 
sizeKeyDeleted, numDirDeleted,
           numKeyRenamed, sizeKeyRenamed, numDirRenamed, 
numMultipartUploadAborted);
-      if (stackCapacitySkippedDirectories > 0) {
-        LOG.info("Lifecycle evaluate for {} skipped {} directories because 
in-memory directory stack "
-            + "exceeded limit {}", bucketName, 
stackCapacitySkippedDirectories, cachedDirMaxCount);
-      }
     }
 
     private void handleAndClearFullList(OmBucketInfo bucket, 
LimitedExpiredObjectList keysList,
@@ -1747,11 +1736,6 @@ public void setKeyDeleteBatchSize(int size) {
     this.keyDeleteBatchSize = size;
   }
 
-  @VisibleForTesting
-  public void setCachedDirMaxCount(long count) {
-    this.cachedDirMaxCount = count;
-  }
-
   // Returns the test-injected OzoneTrash if set, otherwise the live instance
   // from OzoneManager. This is needed because startTrashEmptier() runs after
   // keyManager.start() in all OzoneManager startup paths, so the field cannot
@@ -2206,7 +2190,7 @@ public int compare(RuleListWithDirectoryList o1, 
RuleListWithDirectoryList o2) {
         }
       }
       if (parent == null) {
-        // e.g, dir1 and dir2, dir2 should ahead of dir1, given the 
depth-first and dir's RocksDB key order
+        // e.g,  dir1 and dir2, dir2 should ahead of dir2, given the 
depth-first and dir's RocksDB key order
         return dirList2.get(0).getName().compareTo(dirList1.get(0).getName());
       } else {
         long parentID = parent.getObjectID();
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleServiceConfig.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleServiceConfig.java
index 9fce8c4dd35..603e6071f1b 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleServiceConfig.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleServiceConfig.java
@@ -96,8 +96,8 @@ public class KeyLifecycleServiceConfig extends 
ReconfigurableConfig {
       reconfigurable = true,
       tags = {ConfigTag.OM, ConfigTag.OZONE},
       description = "Max numbers of directory objects held in memory stack for 
recursive FSO bucket evaluating " +
-          "for a lifecycle evaluating task. Once the cached directory objects 
exceeds this limit, the directories " +
-          "which cannot be cached are skipped in this evaluation, and the 
evaluation continues with the cached ones."
+          "for a lifecycle evaluating task. Once the cached directory objects 
exceeds this limit, the evaluation " +
+          "of the involved directories will abort."
   )
   private long cachedDirMaxCount = Defaults.DELETE_CACHED_DIRECTORY_MAX_COUNT;
 
diff --git 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyLifecycleService.java
 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyLifecycleService.java
index 630d9b4096a..c209bfe80e4 100644
--- 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyLifecycleService.java
+++ 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyLifecycleService.java
@@ -568,7 +568,7 @@ void testBucketScanResume(BucketLayout bucketLayout, 
boolean createPrefix) throw
       assertNotNull(state);
 
       // resume the service
-      runSingleLifecycleScanAndDeleteConfiguration(volumeName, bucketName);
+      runSingleLifecycleScan(volumeName, bucketName);
 
       // it should skip the first 3 keys (index 0, 1, 2) since we set 
lastScannedDbKey as index 2.
       // So it deletes only the last 2 keys (index 3 and 4).
@@ -979,98 +979,6 @@ void testNestedFSODirectoryScanResume(BucketLayout 
bucketLayout, int maxSize) th
       deleteLifecyclePolicy(volumeName, bucketName);
     }
 
-    public Stream<Arguments> cachedDirLimitParameters() {
-      return Stream.of(
-          // Root evaluation pushes itself, dir1 and dir2, then overflows at 
dir3 so dir3 and dir30 are skipped.
-          // dir1 evaluation pushes itself and dir4, then overflows at 
dir1/dir5 so dir5 is skipped.
-          // Only dir1/dir4's keys are expired. dir2 and dir4 are expired as 
empty or fully expired directories,
-          // while dir1 is kept since its skipped sub directory dir5 is not 
expired.
-          arguments(3L, 2, 2, 3L),
-          // Root evaluation pushes itself, then overflows at its first sub 
directory, so nothing is evaluated
-          arguments(1L, 0, 0, 4L)
-      );
-    }
-
-    /**
-     * When the in-memory DFS directory stack exceeds 
DELETE_CACHED_DIRECTORY_MAX_COUNT, the directory which
-     * cannot be pushed is skipped with its whole subtree and the following 
siblings, and the evaluation
-     * continues with the directories already on the stack.
-     */
-    @ParameterizedTest
-    @MethodSource("cachedDirLimitParameters")
-    void testFSOScanSkipsDirectoriesWhenCachedDirectoryMaxCountExceeded(long 
cachedDirLimit,
-        int expectedDeletedKeys, int expectedDeletedDirs, long 
expectedSkippedDirectories) throws Exception {
-      final String volumeName = getTestName();
-      final String bucketName = uniqueObjectName("bucket");
-      final int testKeyCount = 8;
-      long initialDeletedKeyCount = getDeletedKeyCount();
-      long initialDeletedDirCount = getDeletedDirectoryCount();
-      long initialKeyCount = getKeyCount(FILE_SYSTEM_OPTIMIZED);
-
-      keyLifecycleService.suspend();
-      keyLifecycleService.setCachedDirMaxCount(cachedDirLimit);
-
-      createVolumeAndBucket(volumeName, bucketName, FILE_SYSTEM_OPTIMIZED,
-          UserGroupInformation.getCurrentUser().getShortUserName());
-      List<OmKeyArgs> keyList = new ArrayList<>();
-      keyList.add(createAndCommitKey(volumeName, bucketName, "dir1/dir4/key0", 
1, null));
-      keyList.add(createAndCommitKey(volumeName, bucketName, "dir1/dir4/key1", 
1, null));
-      keyList.add(createAndCommitKey(volumeName, bucketName, "dir1/dir5/key2", 
1, null));
-      keyList.add(createAndCommitKey(volumeName, bucketName, "dir1/dir5/key3", 
1, null));
-      keyList.add(createAndCommitKey(volumeName, bucketName, 
"dir3/dir6/dir8/key5", 1, null));
-      keyList.add(createAndCommitKey(volumeName, bucketName, 
"dir3/dir6/dir8/key6", 1, null));
-      keyList.add(createAndCommitKey(volumeName, bucketName, 
"dir3/dir6/dir9/key7", 1, null));
-      keyList.add(createAndCommitKey(volumeName, bucketName, 
"dir3/dir6/dir9/key8", 1, null));
-      createDirectory(volumeName, bucketName, "dir2");
-      createDirectory(volumeName, bucketName, "dir3/dir7");
-      createDirectory(volumeName, bucketName, "dir30");
-
-      assertEquals(testKeyCount, keyList.size());
-      GenericTestUtils.waitFor(
-          () -> getKeyCount(FILE_SYSTEM_OPTIMIZED) - initialKeyCount == 
testKeyCount, WAIT_CHECK_INTERVAL, 1000);
-      awaitKeyCacheDrained(FILE_SYSTEM_OPTIMIZED, volumeName, bucketName);
-      awaitDirCacheDrained(volumeName, bucketName);
-
-      ZonedDateTime date = 
ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(LONG_EXPIRE_SECONDS);
-      OmLCFilter.Builder filter = getOmLCFilterBuilder("", null, null);
-      createLifecyclePolicy(volumeName, bucketName, FILE_SYSTEM_OPTIMIZED, 
null, filter.build(), date.toString(), true);
-
-      GenericTestUtils.LogCapturer logCapturer = 
GenericTestUtils.LogCapturer.captureLogs(
-          LoggerFactory.getLogger(KeyLifecycleService.class));
-      runSingleLifecycleScanAndDeleteConfiguration(volumeName, bucketName);
-
-      String output = logCapturer.getOutput();
-      String bucketKey = metadataManager.getBucketKey(volumeName, bucketName);
-      assertThat(output).contains("Lifecycle evaluate for " + bucketKey + " 
skipped "
-          + expectedSkippedDirectories + " directories because in-memory 
directory stack exceeded limit "
-          + cachedDirLimit);
-      assertThat(output).doesNotContain("Skip evaluate " + volumeName + "/" + 
bucketName);
-
-      GenericTestUtils.waitFor(() -> getDeletedKeyCount() - 
initialDeletedKeyCount == expectedDeletedKeys,
-          WAIT_CHECK_INTERVAL, 10000);
-      assertEquals(testKeyCount - expectedDeletedKeys, 
getKeyCount(FILE_SYSTEM_OPTIMIZED) - initialKeyCount);
-      GenericTestUtils.waitFor(() -> getDeletedDirectoryCount() - 
initialDeletedDirCount == expectedDeletedDirs,
-          WAIT_CHECK_INTERVAL, 10000);
-      // The scan still completes, so the next scan starts from the beginning 
instead of resuming
-      GenericTestUtils.waitFor(() -> {
-        try {
-          OmLifecycleScanState state = 
metadataManager.getLifecycleScanStateTable().get(bucketKey);
-          return state != null && state.getScanEndTime() != null;
-        } catch (IOException e) {
-          return false;
-        }
-      }, WAIT_CHECK_INTERVAL, 10000);
-
-      
keyLifecycleService.setCachedDirMaxCount(KeyLifecycleServiceConfig.Defaults.DELETE_CACHED_DIRECTORY_MAX_COUNT);
-      createLifecyclePolicy(volumeName, bucketName, FILE_SYSTEM_OPTIMIZED, 
null, filter.build(), date.toString(),
-          true);
-      runSingleLifecycleScanAndDeleteConfiguration(volumeName, bucketName);
-
-      GenericTestUtils.waitFor(() -> (getDeletedKeyCount() - 
initialDeletedKeyCount) == testKeyCount,
-          WAIT_CHECK_INTERVAL, 10000);
-      assertEquals(0, getKeyCount(FILE_SYSTEM_OPTIMIZED) - initialKeyCount);
-    }
-
     @ParameterizedTest
     @MethodSource("parameters1")
     void testOneKeyExpired(BucketLayout bucketLayout, boolean createPrefix) 
throws IOException,
@@ -1181,7 +1089,7 @@ void testDirectorySkippedAfterResume(String 
lastScannedDir, String[] skippedDir,
       GenericTestUtils.LogCapturer logCapturer = 
GenericTestUtils.LogCapturer.captureLogs(
           LoggerFactory.getLogger(KeyLifecycleService.class));
       // Resume the service
-      runSingleLifecycleScanAndDeleteConfiguration(volumeName, bucketName);
+      runSingleLifecycleScan(volumeName, bucketName);
 
       GenericTestUtils.waitFor(() ->
           (getDeletedKeyCount() - initialDeletedKeyCount) == expectedDeleted, 
WAIT_CHECK_INTERVAL, 10000);
@@ -1264,7 +1172,7 @@ void testLastScannedKeySeek(boolean keyBelongToDir) 
throws Exception {
 
       GenericTestUtils.LogCapturer logCapturer = 
GenericTestUtils.LogCapturer.captureLogs(
           LoggerFactory.getLogger(KeyLifecycleService.class));
-      runSingleLifecycleScanAndDeleteConfiguration(volumeName, bucketName);
+      runSingleLifecycleScan(volumeName, bucketName);
 
       // dir2 is skipped since dir2 > dir1. dir1 is fully evaluated only when 
lastScannedKey does not
       // belong to it, otherwise the scan seeks past its last key and nothing 
is left to expire.
@@ -1327,6 +1235,7 @@ void testCacheOnlyKeyNotSavedAsLastScannedKey() throws 
Exception {
       tableField.set(metadataManager, spyTable);
       try {
         runSingleLifecycleScan(volumeName, bucketName, false);
+
         GenericTestUtils.waitFor(() ->
             (getDeletedKeyCount() - initialDeletedKeyCount) == 3, 
WAIT_CHECK_INTERVAL, 10000);
         assertEquals(0, getKeyCount(FILE_SYSTEM_OPTIMIZED) - initialKeyCount);
@@ -1399,7 +1308,7 @@ void testBucketRootScannedDirResume(BucketLayout layout) 
throws Exception {
       metadataManager.getLifecycleScanStateTable().addCacheEntry(new 
CacheKey<>(bucketKey),
           CacheValue.get(1L, scanState));
           
-      runSingleLifecycleScanAndDeleteConfiguration(volumeName, bucketName);
+      runSingleLifecycleScan(volumeName, bucketName);
 
       // It should seek to key2. key1 is skipped, key2 is skipped too.
       // So key1 and key2 are skipped, key3 is deleted.
@@ -3765,7 +3674,6 @@ private void cleanUpService() throws Exception {
         keyLifecycleService.setMoveToTrashEnabled(true);
         
keyLifecycleService.setKeyDeleteBatchSize(conf.getInt(KeyLifecycleServiceConfig.Keys.DELETE_BATCH_SIZE,
             KeyLifecycleServiceConfig.Defaults.DELETE_BATCH_SIZE));
-        
keyLifecycleService.setCachedDirMaxCount(KeyLifecycleServiceConfig.Defaults.DELETE_CACHED_DIRECTORY_MAX_COUNT);
         keyLifecycleService.resume();
       }
     }
@@ -3773,7 +3681,7 @@ private void cleanUpService() throws Exception {
 
   // Runs exactly one scan: without dropping the policy first, the next scan 
starts SERVICE_INTERVAL
   // later and deletes the objects the caller expects to remain.
-  private void runSingleLifecycleScanAndDeleteConfiguration(String volume, 
String bucket)
+  private void runSingleLifecycleScan(String volume, String bucket)
       throws IOException, TimeoutException, InterruptedException {
     runSingleLifecycleScan(volume, bucket, true);
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to