Skip to content

Comments

indexer: fix context reuse in bridge filter query#2496

Merged
mergify[bot] merged 2 commits intoethereum-optimism:developfrom
tuxcanfly:tux/fix-indexer-ctx-reuse
Apr 24, 2022
Merged

indexer: fix context reuse in bridge filter query#2496
mergify[bot] merged 2 commits intoethereum-optimism:developfrom
tuxcanfly:tux/fix-indexer-ctx-reuse

Conversation

@tuxcanfly
Copy link
Contributor

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 FilterWithdrawalInitiatedWithRetry call 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 FilterWithdrawalInitiatedWithRetry method as the first argument, then the child context is drawn from it and used for the API call by using Opts.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 cancel for the retry context in the error case. This has been fixed.

@changeset-bot
Copy link

changeset-bot bot commented Apr 23, 2022

🦋 Changeset detected

Latest commit: 311b601

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eth-optimism/indexer Patch

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

@mergify mergify bot requested review from Inphi and mslipper April 23, 2022 23:43
@mergify
Copy link
Contributor

mergify bot commented Apr 23, 2022

This PR changes implementation code, but doesn't include a changeset. Did you forget to add one?

Copy link
Collaborator

@mslipper mslipper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.

@mergify
Copy link
Contributor

mergify bot commented Apr 24, 2022

This PR has been added to the merge queue, and will be merged soon.

@mergify mergify bot requested a review from Inphi April 24, 2022 05:13
@mergify mergify bot merged commit d7bb962 into ethereum-optimism:develop Apr 24, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 24, 2022

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
@mslipper mslipper mentioned this pull request Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants