Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consumer: bugfix fetch concurrency loop
This loop has been a bit problematic... The desire fetch channel needed to be unbuffered. By being buffered, we could race towards a deadlock * source sends to desireFetchCh, is buffered * source seeds context canceled, tries sending to cancelFetchCh * session concurrently sees context canceled * session has not drained desireFetchCh, sees activeFetches is 0 * session exits * source permanently hangs sending to desireFetchCh We also theoretically could have made activeFetches negative if the cancel was seen before the desire. By forcing the desire channel to be unbuffered, we ensure that the desire is tracked properly in the wantFetch slice. The logic here could be cleaned up a little bit -- particularly, we could return earlier if active fetches is zero, rather than continue spinning through desired fetches and starting them only for them to die -- but this is a small optimization that would save only a bit of CPU. I'm happy to keep the logic as is for now and focus on the bugfix. Closes #198.
- Loading branch information