Skip to content

Commit d2c1bf4

Browse files
fix(csharp): always complete result queue when download loop exits
The download loop's finally block only called CompleteAdding() on the result queue when the downloader itself had an error. When the fetcher failed mid-stream (e.g. warehouse stopped), the downloader had no error of its own, so the queue was left open — empty but not completed. On retry, BlockingCollection.Take() blocked forever waiting for items that would never arrive, deadlocking the Mashup Container thread and causing Power BI to hang with a spinner instead of showing an error. Now CompleteAdding() is called on every exit path, so Take() on an empty queue throws InvalidOperationException (caught by existing handler) instead of blocking, allowing the fetcher error to propagate. Co-authored-by: Isaac
1 parent dcec15e commit d2c1bf4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

csharp/src/Reader/CloudFetch/CloudFetchDownloader.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,20 @@ await _activityTracer.TraceActivityAsync(async activity =>
437437
new("total_time_sec", overallStopwatch.ElapsedMilliseconds / 1000.0)
438438
]);
439439

440-
// If there's an error, add the error to the result queue
440+
// Always mark the result queue as complete when the download
441+
// loop exits. Without this, a subsequent Take() call would
442+
// block forever on an empty, non-completed queue if the caller
443+
// retries after an exception (e.g. a fetcher error that the
444+
// downloader doesn't know about).
441445
if (HasError)
442446
{
443447
CompleteWithError(activity);
444448
}
449+
else
450+
{
451+
try { _resultQueue.CompleteAdding(); }
452+
catch (InvalidOperationException) { /* already completed */ }
453+
}
445454
}
446455
});
447456
}

0 commit comments

Comments
 (0)