[ 
https://issues.apache.org/jira/browse/HDFS-17842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18064139#comment-18064139
 ] 

ASF GitHub Bot commented on HDFS-17842:
---------------------------------------

balodesecurity opened a new pull request, #8333:
URL: https://github.com/apache/hadoop/pull/8333

   ### Problem
   After HDFS-17263, deleting `.Trash/Current/` or `.Trash/<checkpoint>/` via 
the RBF router fails with:
   
       The operation is not allowed because there are mount points: 
<mount-points> under the path: /user/alice/.Trash/Current
   
   However, deleting `.Trash/` itself succeeds. The regression was introduced 
by HDFS-17263 which removed the trailing `/` from the `isTrashPath` regex 
pattern.
   
   ### Root Cause
   `RouterClientProtocol.delete()` calls `getLocationsForPath(src, 
failIfLocked=true)`, which calls `MountTableResolver.getMountPoints(src)`. When 
`src` is a trash-current path like `/user/alice/.Trash/Current`, 
`getMountPoints` detects it as a trash path via `isTrashPath()`, subtracts the 
trash prefix via `subtractTrashCurrentPath()`, and gets an empty string `""`. 
The code then queries the mount table tree with `subMap("", ""+MAX_VALUE)`, 
which returns **all** mount table entries. 
`FileSubclusterResolver.getMountPoints("", allKeys)` therefore returns a 
non-null list of all mount point names, causing `getLocationsForPath` to throw 
`AccessControlException`.
   
   Before HDFS-17263, `isTrashPath` required a trailing `/`, so 
`.Trash/Current` (without trailing slash) was not recognized as a trash path 
and `getMountPoints` would correctly look for mount points directly under 
`.Trash/Current` — finding none.
   
   ### Fix
   In `MountTableResolver.getMountPoints()`, after applying 
`subtractTrashCurrentPath()`, if the resulting path is empty (meaning the input 
was exactly the trash Current or checkpoint directory with no sub-path), return 
`null` immediately. An empty result means the path is the trash checkpoint 
directory itself, which never hosts RBF mount points.
   
   ### Testing
   Added `testDeleteTrashCurrentAndCheckpoint()` to `TestRouterTrash` which:
   1. Moves a file to trash via the router
   2. Verifies that `fs.delete(.Trash/Current, recursive=true)` succeeds
   3. Verifies that `fs.delete(.Trash, recursive=true)` also succeeds
   
   JIRA: https://issues.apache.org/jira/browse/HDFS-17842




> RBF: Unable to delete certain files or directories under trash path
> -------------------------------------------------------------------
>
>                 Key: HDFS-17842
>                 URL: https://issues.apache.org/jira/browse/HDFS-17842
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: rbf
>            Reporter: Takanobu Asanuma
>            Priority: Major
>
> With HDFS-17263, attempts to delete files or directories under the trash path 
> fail when specifying `.Trash/*` or `.Trash/Current/`. However, deleting the 
> `.Trash` directory itself succeeds.
> {noformat}
> # 1. Specifying .Trash/* → Failed
> $ hadoop fs -rm -r -skipTrash '/user/alice/.Trash/*'
> rm: The operation is not allowed because there are mount points: ... under 
> the path: /user/alice/.Trash/Current
> # 2. Specifying .Trash/Current/ → Failed
> $ hadoop fs -rm -r -skipTrash '/user/alice/.Trash/Current/'
> rm: The operation is not allowed because there are mount points: ... under 
> the path: /user/alice/.Trash/Current
> # 3. Deleting .Trash directly → Succeeded
> -bash-4.2$ hadoop fs -rm -r -skipTrash '/user/alice/.Trash/'
> Deleted /user/alice/.Trash
> {noformat}
> These operations succeeded prior to HDFS-17263.
> This issue is reported by Haruka Ogawa and Kai Hirayama.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to