Repository navigation
bulk: fix deadlock in recursive directory expansion - #8317
Open
DmitryLitvintsev wants to merge 1 commit into
Open
DmitryLitvintsev wants to merge 1 commit into
DmitryLitvintsev wants to merge 1 commit into
Conversation
Motivation: ----------- Issue #8062 reports that recursive bulk requests (e.g. DELETE with expandDirectories=ALL) on large directory trees stay in RUNNING state forever, with "Available permits for directory listing" dropping to 0. Increasing bulk.limits.dir-list-semaphore only delays the hang and, at very high values, exhausts the JVM memory. A directory listing task holds a dir-list permit while iterating over the directory and, for each subdirectory found, blocks acquiring a permit for the child listing. Once the number of directories being listed concurrently reaches the number of permits, all permits are held by tasks waiting for permits and nothing progresses. Since the semaphore is shared by all requests, a single large request also blocks directory listing for every other request. A similar cycle exists for an initial directory target holding an in-flight permit while waiting for a dir-list permit. Modification: ------------- Replaced the dir-list semaphore with a new non-blocking BulkTaskThrottle, shared by all requests. Directory listing tasks are registered as running immediately (so that the transition to directory processing still waits for them) and queued in the throttle; a queued listing is launched as soon as a permit is available, and every released permit launches the next queued listing, regardless of which request it belongs to. Submission never blocks, so a listing task can queue its subdirectories while holding its own permit. A listing cancelled while queued returns its permit without running. A listing rejected by the executor fails the request instead of silently skipping the subtree. Added "Directory listings waiting for permit" to the service info output. Added unit tests for BulkTaskThrottle and for BulkRequestContainerJob expanding a directory tree wider than the number of listing permits (this test hangs without the fix), including cancellation during expansion. Result: ------- Recursive bulk requests on large directory trees complete with the default bulk.limits.dir-list-semaphore, which now only limits the number of concurrent directory listings sent to PnfsManager. Ticket: #8062 Acked-by: Tigran Target: trunk Request: 11.2, 12.0, 12.1 Require-book: no Require-notes: yes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
Issue #8062 reports that recursive bulk requests (e.g. DELETE with expandDirectories=ALL) on large directory trees stay in RUNNING state forever, with "Available permits for directory listing" dropping to 0. Increasing bulk.limits.dir-list-semaphore only delays the hang and, at very high values, exhausts the JVM memory.
A directory listing task holds a dir-list permit while iterating over the directory and, for each subdirectory found, blocks acquiring a permit for the child listing. Once the number of directories being listed concurrently reaches the number of permits, all permits are held by tasks waiting for permits and nothing progresses. Since the semaphore is shared by all requests, a single large request also blocks directory listing for every other request. A similar cycle exists for an initial directory target holding an in-flight permit while waiting for a dir-list permit.
Modification:
Replaced the dir-list semaphore with a new non-blocking BulkTaskThrottle, shared by all requests. Directory listing tasks are registered as running immediately (so that the transition to directory processing still waits for them) and queued in the throttle; a queued listing is launched as soon as a permit is available, and every released permit launches the next queued listing, regardless of which request it belongs to. Submission never blocks, so a listing task can queue its subdirectories while holding its own permit.
A listing cancelled while queued returns its permit without running. A listing rejected by the executor fails the request instead of silently skipping the subtree.
Added "Directory listings waiting for permit" to the service info output. Added unit tests for BulkTaskThrottle and for BulkRequestContainerJob expanding a directory tree wider than the number of listing permits (this test hangs without the fix), including cancellation during expansion.
Result:
Recursive bulk requests on large directory trees complete with the default bulk.limits.dir-list-semaphore, which now only limits the number of concurrent directory listings sent to PnfsManager.
Ticket: #8062
Acked-by: Tigran
Target: trunk
Request: 11.2, 12.0, 12.1
Require-book: no
Require-notes: yes