Skip to content
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

reconnecting rpc: ensure poll order to avoid outdated subscription ID on reconnect #1567

Open
niklasad1 opened this issue May 2, 2024 · 1 comment · May be fixed by #1620
Open

reconnecting rpc: ensure poll order to avoid outdated subscription ID on reconnect #1567

niklasad1 opened this issue May 2, 2024 · 1 comment · May be fixed by #1620
Assignees

Comments

@niklasad1
Copy link
Member

niklasad1 commented May 2, 2024

Originally posted by @lexnv in #1505 (comment)

TLDR, when a re-connection occurs the poll order of "pending futures" should wait until chainHead__follow returns then fetch the updated subscription ID.

Currently we have a hack to retry these a calls a few times.

@niklasad1 niklasad1 changed the title reconnecting rpc: ensure poll order to avoid outdated subscription ID on restart reconnecting rpc: ensure poll order to avoid outdated subscription ID on reconnect May 2, 2024
@jsdw
Copy link
Collaborator

jsdw commented May 3, 2024

One idea offhand (but maybe not the best one!) is something like (I can't remember if I wrote this somewhere already):

  1. Keep a "connection count" in the follow subscription thing, which is returned along with the subscription ID in the ready event and/or is available with every event (like the subscription ID might be).
  2. When we get the data we want from the follow subscription, also note the current connection count at that time.
  3. If some call that depends on data from follow subscription returns a DisconnectedWillReconnect, then go back to 2, but wait until the connection count increments before trying to do anything with the data.

So for a real example this might mean that we:

  • get a subscription ID and note the connection count when we do
  • call eg chainHead_v1_header(sub_id)
    • if the chainHead call return an error then loop around and try to get subscription Id again, waiting for an Id that has a connection count which is >=1 higher.

This should ensure that the follow subscription has reconnected at least once since we got the disconnected error, and isn't stale :)

@pkhry pkhry self-assigned this May 24, 2024
pkhry added a commit that referenced this issue May 29, 2024
@pkhry pkhry linked a pull request May 29, 2024 that will close this issue
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 a pull request may close this issue.

3 participants