indexer: fix context reuse in bridge filter query#2496
Merged
mergify[bot] merged 2 commits intoethereum-optimism:developfrom Apr 24, 2022
Merged
indexer: fix context reuse in bridge filter query#2496mergify[bot] merged 2 commits intoethereum-optimism:developfrom
mergify[bot] merged 2 commits intoethereum-optimism:developfrom
Conversation
🦋 Changeset detectedLatest commit: 311b601 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
This PR changes implementation code, but doesn't include a changeset. Did you forget to add one? |
Inphi
approved these changes
Apr 24, 2022
Contributor
|
This PR has been added to the merge queue, and will be merged soon. |
Contributor
|
This PR is next in line to be merged, and will be merged as soon as checks pass. |
nebojsa94
pushed a commit
to Tenderly/optimism
that referenced
this pull request
Apr 26, 2022
…2496) * fix (indexer): bridge filter query - fix ctx reuse * changeset: indexer patch - fix context reuse
Merged
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
This PR addresses an issue with the indexer where a long running service stalls with the error:
context deadline exceeded.This was happening because the context for the first
FilterWithdrawalInitiatedWithRetrycall was being re-used in all subsequent calls. This means that if for whatever reason, one request to the API fails to complete within the deadline, all subsequent calls will fail with the same error.I have reproduced the underlying cause of the error in this minimal gist: https://gist.github.com/tuxcanfly/28bee3ef233764d9d7ea6d63cbae48f6
With this fix the parent context remains separate from all the retry context which are all the direct children of the parent context.
The parent context is passed in to the
FilterWithdrawalInitiatedWithRetrymethod as the first argument, then the child context is drawn from it and used for the API call by usingOpts.Context. Separating out the contexts like this avoids the confusion around the context scope which lead to this bug.Aside from this reuse bug, we were also not calling
cancelfor the retry context in the error case. This has been fixed.