-
Notifications
You must be signed in to change notification settings - Fork 934
Don't delay retryable operations #3270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9b371a9
to
2187e60
Compare
Binary Size ReportAffected SDKs
Test Logs |
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.
A couple of comments on the PR's description:
One of the behavior changes of
enqueueRetryable
was...
Can you add a link to the PR with the change?
This means that any operation that was scheduled after the second retryable operation will run before this run.
Can you rephrase and/or expand this sentence? I don't fully understand how this follows from the behavior change mentioned in the previous sentence.
@@ -313,6 +312,65 @@ describe('AsyncQueue', () => { | |||
expect(completedSteps).to.deep.equal([1, 1, 2]); | |||
}); | |||
|
|||
it('Doesn not delay retryable operations that succeed', async () => { |
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.
Nit: s/Doesn/Does/.
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.
Oops. Fixed.
private async retryNextOp(): Promise<void> { | ||
const op = this.retryableOps.shift(); | ||
|
||
if (op) { |
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.
Can you use an early return instead to reduce nestedness?
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.
Updated. I also ended up rewriting this a little bit to make flow easier to follow.
}); | ||
} | ||
|
||
this.backoff.backoffAndRun(() => this.retryNextOp()); |
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.
Question: why is backoff invoked in the successful case?
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.
I added a comment.
@@ -207,9 +207,9 @@ export class AsyncQueue { | |||
// The last promise in the queue. | |||
private tail: Promise<unknown> = Promise.resolve(); | |||
|
|||
// The last retryable operation. Retryable operation are run in order and | |||
// A list of retryable operations Retryable operation are run in order and |
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.
Nit: missing full stop.
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.
Fixed
@@ -207,9 +207,9 @@ export class AsyncQueue { | |||
// The last promise in the queue. | |||
private tail: Promise<unknown> = Promise.resolve(); | |||
|
|||
// The last retryable operation. Retryable operation are run in order and | |||
// A list of retryable operations Retryable operation are run in order and |
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.
Nit: should be Retryable operations are run in order...
(i.e. plural).
@@ -787,6 +787,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => { | |||
.expectActiveTargets({ query }) | |||
// We are now user 2 | |||
.expectEvents(query, { removed: [doc1], fromCache: true }) | |||
.runTimer(TimerId.AsyncQueueRetry) |
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.
Question: why is this change necessary?
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.
The previous implementation used "enqueue" to run the next delayed operation, this implementation uses "enqueueWithBackoff". I verified that the backoff is 0 at this step, but even operations with zero backoff aren't automatically drained in the SpecTestRunner.
614b1d7
to
0ee1207
Compare
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.
Can you please take a look at the comments regarding the PR's description? Thanks!
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.
PR comment updated.
One of the behavior changes of
enqueueRetryable
(#2879) was that it only scheduled the next operation when the first operation succeeds. This means that any operation that was scheduled after the second retryable operation will run before this run:While theoretically okay, this still seems to cause some issues with the user change. This PR changes the retry behavior so that operations run in the original order if no failure occurred.
Addresses #3218