-
Notifications
You must be signed in to change notification settings - Fork 25
fix: Adjust big segments logic to prevent duplicate polls. #225
Conversation
@@ -43,8 +44,9 @@ Logger logger | |||
_taskExecutor = taskExecutor; | |||
_logger = logger; | |||
|
|||
_initialPoll = Task.Run(PollStoreAndUpdateStatusAsync); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually run the first task instead of using the repeating task.
return ret.Value; | ||
} | ||
return AsyncUtils.WaitSafely(() => PollStoreAndUpdateStatusAsync()); | ||
return ret ?? _initialPoll.GetAwaiter().GetResult(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no value, then that first poll has not completed. Wait for it to complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that the initial task is still executing by the time the first repeating task runs? I suppose it may be extremely unlikely given the real world values of StatusPollInterval
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It theoretically is possible. I did consider if there was a way to use the most recent task, but the complexity didn't seem worth it. If at any point a repeating task does complete, then we would ideally hit the first code path subsequently.
return ret.Value; | ||
} | ||
return AsyncUtils.WaitSafely(() => PollStoreAndUpdateStatusAsync()); | ||
return ret ?? _initialPoll.GetAwaiter().GetResult(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that the initial task is still executing by the time the first repeating task runs? I suppose it may be extremely unlikely given the real world values of StatusPollInterval
.
🤖 I have created a release *beep* *boop* --- ## [8.5.1](8.5.0...8.5.1) (2024-06-03) ### Bug Fixes * Adjust big segments logic to prevent duplicate polls. ([#225](#225)) ([4202165](4202165)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
The contract tests attempt to determine that the SDK is not making redundant polls, and sometimes this test would fail.
Theoretically this could also affect a server handling requests on many threads which concurrently request status before the first request has completed.