Chi-Hsuan Huang created HDDS-17998:
--------------------------------------
Summary: Lifecycle Expiration rule without a prefix never expires
keys in FSO subdirectories
Key: HDDS-17998
URL: https://issues.apache.org/jira/browse/HDDS-17998
Project: Apache Ozone
Issue Type: Bug
Components: OM
Reporter: Chi-Hsuan Huang
On an FSO bucket, a lifecycle Expiration rule that has no prefix (a {{Tag}}
filter, or an {{And}} filter with tags and no {{Prefix}}) only expires matching
keys directly under the bucket root. Matching keys in any subdirectory are
never deleted. On an OBS bucket the same rule deletes all of them.
*Reproduction*
Keys {{a}}, {{dir1/a}} and {{dir1/dir2/b}} are tagged {{app=spark}}. An expired
Expiration rule filters on that tag. After {{KeyLifecycleService}} runs,
waiting about 10 more service intervals:
||Rule filter||FSO||OBS||
|{{Tag}} only|1 of 3 deleted ({{a}})|3 of 3 deleted|
|{{And}} with tags, no {{Prefix}}|1 of 3 deleted ({{a}})|3 of 3 deleted|
|{{And}} with {{Prefix}} {{""}} and tags|3 of 3 deleted|3 of 3 deleted|
Untagged control keys were kept in every case. Reproduced with a temporary test
in {{TestKeyLifecycleService}} on master {{ff77145ac99a}}.
*Cause*
The FSO directory walk keeps a subdirectory only if some rule has a non-null
effective prefix that the subdirectory path starts with
([KeyLifecycleService.java#L825|https://github.com/apache/ozone/blob/ff77145ac99a6ff8c59f94404233582bcaf5f844/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleService.java#L817-L830]).
{{OmLCRule.getEffectivePrefix()}} returns {{null}} for a rule without any
prefix
([OmLCRule.java#L97|https://github.com/apache/ozone/blob/ff77145ac99a6ff8c59f94404233582bcaf5f844/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCRule.java#L97-L102]),
so every subdirectory is dropped. {{getRuleUnion}} already treats {{null}} and
{{""}} the same (scan from the bucket root), so only this check differs.
*Possible fix*
Keep the subdirectory when a rule's effective prefix is {{null}}, the same as
{{""}}. With that change the reproduction deletes 3 of 3 on FSO, and all
{{TestKeyLifecycleService}} tests pass.
Points to check with the fix (not verified yet):
# A directory emptied by a tag rule is not deleted itself (reading
{{OmLCFilter.match(OmDirectoryInfo, ...)}}, tag and {{And}} filters do not
match directories).
# A bucket with both a prefix rule and a tag-only rule: each rule still deletes
only its own keys.
# A tag-only rule now walks the whole FSO bucket, which OBS already does. Worth
a note for large buckets.
Found while reviewing HDDS-16151 (PR #12170): the new {{x-amz-expiration}}
header reports an expiry date for such nested keys, but the service never
deletes them.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]