[data] Prevent download deadlock on wide directory trees#287
Merged
Conversation
Signed-off-by: Konstantin Kozoriz <konstantin.kozoriz@flant.com>
AleksZimin
previously approved these changes
Feb 26, 2026
ipaqsa
reviewed
Mar 2, 2026
ipaqsa
reviewed
Mar 2, 2026
ipaqsa
reviewed
Mar 2, 2026
ipaqsa
requested changes
Mar 2, 2026
Signed-off-by: Konstantin Kozoriz <konstantin.kozoriz@flant.com>
Signed-off-by: Konstantin Kozoriz <konstantin.kozoriz@flant.com>
kneumoin
approved these changes
Mar 3, 2026
ipaqsa
approved these changes
Mar 3, 2026
ldmonster
approved these changes
Mar 3, 2026
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.
Description
Problem
recursiveDownloadused a blocking semaphore acquire (sem <- struct{}{}) beforelaunching each child goroutine. When the directory tree had more direct children
than the semaphore capacity (default: 10), all running goroutines blocked trying
to schedule the next level while holding their semaphore slot - causing a deadlock.
Root Cause
Every active goroutine tried to acquire a new semaphore slot before yielding its
own, which deadlocked as soon as all 10 slots were occupied by tasks that each
needed a free slot to proceed.
Fix
Replace the blocking send with a non-blocking
select:Before fix
After fix