Copilot commented on code in PR #12028:
URL: https://github.com/apache/ozone/pull/12028#discussion_r4546244401
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleService.java:
##########
@@ -845,6 +845,10 @@ private void evaluateKeyAndDirTable(OmBucketInfo bucket,
long volumeObjId, Table
keySetInCache.add(entry.getKey().getCacheKey());
String keyPath = currentDirPath.isEmpty() ? key.getKeyName() :
currentDirPath + OM_KEY_PREFIX + key.getKeyName();
+ // skip hsync'ed keys that are still open for write
+ if (key.isHsync()) {
+ continue;
Review Comment:
The new test drains the key cache and adds the hsync marker only to the
persisted table, so it never exercises this guard and would still pass if this
cache-side check were removed. Please add an FSO case with a cache-resident
hsync key, using the cache-entry setup in
`TestKeyLifecycleService.testCacheOnlyKeyNotSavedAsLastScannedKey`, and verify
that it survives while ordinary expired keys are deleted. This covers the path
used before an hsync update is flushed to the table.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyLifecycleService.java:
##########
@@ -1815,6 +1816,45 @@ void testExpireKeysUnderDirectory(BucketLayout
bucketLayout) throws IOException,
deleteLifecyclePolicy(volumeName, bucketName);
}
+ @ParameterizedTest
+ @ValueSource(strings = {"FILE_SYSTEM_OPTIMIZED", "OBJECT_STORE"})
+ void testHsyncKeyNotExpired(BucketLayout bucketLayout) throws Exception {
+ final String volumeName = getTestName();
+ final String bucketName = uniqueObjectName("bucket");
+ String keyPrefix = "dir1/key";
+ long initialDeletedKeyCount = getDeletedKeyCount();
+ long initialKeyCount = getKeyCount(bucketLayout);
+ createKeys(volumeName, bucketName, bucketLayout, KEY_COUNT, 1,
keyPrefix, null);
+ awaitKeyCacheDrained(bucketLayout, volumeName, bucketName);
+
+ // mark one key as hsync'ed, still open for write
+ Table<String, OmKeyInfo> keyTable =
metadataManager.getKeyTable(bucketLayout);
+ String hsyncKey = null;
+ try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>>
iter = keyTable.iterator()) {
+ while (iter.hasNext() && hsyncKey == null) {
+ Table.KeyValue<String, OmKeyInfo> kv = iter.next();
+ OmKeyInfo keyInfo = kv.getValue();
+ if (volumeName.equals(keyInfo.getVolumeName()) &&
bucketName.equals(keyInfo.getBucketName())) {
+ hsyncKey = kv.getKey();
+ keyTable.put(hsyncKey,
keyInfo.toBuilder().addMetadata(HSYNC_CLIENT_ID, "1").build());
+ }
+ }
+ }
+ assertNotNull(hsyncKey);
+
+ ZonedDateTime date =
ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(EXPIRE_SECONDS);
+ createLifecyclePolicy(volumeName, bucketName, bucketLayout, "dir1/",
null, date.toString(), true);
Review Comment:
The FSO directory-retention assertion does not exercise protection of a
directory containing an hsync key: `dir1/` is the rule's exact prefix, so
`evaluateKeyAndDirTable` explicitly exempts `dir1` from expiration regardless
of its child counts. Use an empty prefix (or place the keys in a nested
directory below the prefix) so the directory is otherwise eligible for
expiration. This will catch regressions where skipped hsync keys are no longer
counted as live children.
--
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]