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

   Add three NameNode settings (all 0 = disabled by default) to limit how long 
`getListing` and `getContentSummary` hold the FSNamesystem read lock. With all 
three at 0 the code paths behave exactly as before.
   
   **`dfs.namenode.listing.max-lock-hold-ms`**
   
   `getListing` stops adding entries to a page once it has spent this long 
building the page under the read lock, and returns the entries built so far (at 
least one) with `remainingEntries > 0`. Clients already continue from the last 
returned name (`DistributedFileSystem.listStatusInternal`, WebHDFS 
`LISTSTATUS`), so a shorter page needs no client change. Not applied to paths 
inside a snapshot: every page there first rebuilds the snapshot view of the 
directory, so shorter pages would cost more in total. Metric: 
`ListingPagesCutByTime`.
   
   **`dfs.content-summary.max-lock-hold-ms`**
   
   A content summary already relinquishes the read lock every 
`dfs.content-summary.limit` entries. It now also does so once it has held the 
lock this long. With a time limit set, `yield()` is also checked between the 
children of a directory, so one large directory no longer keeps the lock until 
it is fully counted; the existing repositioning by name after a yield handles 
it.
   
   **`dfs.content-summary.max-time-ms`**
   
   A content summary running longer than this is aborted and the client gets an 
`IOException`. The computation is read-only, so there is nothing to undo; the 
abort is raised while the locks are held and they are released by the existing 
`finally` blocks. Metric: `ContentSummaryTimedOut`.
   
   The write lock is not affected. `getQuotaUsage` is covered when it falls 
back to `getContentSummaryInt` (directory without a quota); with a quota set it 
returns the cached counters and does not walk the tree. `getBatchedListing` 
gets the page budget for each path (it calls `getListingInt`), but its single 
read lock across up to `dfs.batched.ls.limit` paths is not time-limited as a 
whole.
   
   ### How was this patch tested?
   
   `TestListingAndContentSummaryTimeLimits` injects slowness through test hooks 
(no timing assumptions about the machine) and checks:
   
   - Default behaviour unchanged
   - Pages cut and listings still complete and in order
   - No duplicates with concurrent creates
   - Snapshot paths not cut
   - Content summary aborted after the deadline and still correct without it
   - Time-based yields happen only when configured
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [x] Object storage: N/A — HDFS NameNode only, no object storage
   - [x] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? No new dependencies
   - [x] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files? N/A
   
   ### AI Tooling
   
   - [x] The PR includes the phrase "Contains content generated by Claude 
(Anthropic)"
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude (Anthropic).


-- 
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]

Reply via email to