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

Fix/ws timeout filter not removed #147

Merged
merged 4 commits into from
Aug 26, 2022

Conversation

DarianShawn
Copy link
Collaborator

Description

The jsonrpc filter was not removed elegantly when timeout, and might block querying even the whole program in some extreme cases.

When triggered, it kept printing log like that:

dogechain.filter: filterBase timeout: id=46eeaded-d726-4202-b4d1-f338ab1427a8 expiresAt="2022-08-25 17:56:25"
dogechain.filter: failed to uninstall filter: id=46eeaded-d726-4202-b4d1-f338ab1427a8
dogechain.filter: filterBase timeout: id=46eeaded-d726-4202-b4d1-f338ab1427a8 expiresAt="2022-08-25 17:56:25"
dogechain.filter: failed to uninstall filter: id=46eeaded-d726-4202-b4d1-f338ab1427a8
// repeated on and on...

The PR fixes this issue. Here is the solution.

We use only one timer and reset it for the timeout checking, and do nothing when the timer fired.
The timer puts down the responsibility of handling the business, its only purpose is to make the loop go round.

That makes sense.
If the node is idle, it should not wait too long for the hurry serving.
If the node is busy, it should focus on the current job instead of distracted from dealing with clutter.
And finally, It shouldn't bordered by the timeout filters, so we remove all those outdated filters once and for all.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

Manual tests

  1. Set up a dev mode node.
  2. Send several eth_newBlockFilter, eth_newLogFilter, eth_getFilterChanges requests using curl or WebSocket client, in order to trigger with different timeout timestamps.
  3. Watch the logs.

We should find only one 'adding', 'deletion' for each filter, and never get any repeated timeout logs no matter how many times we test.

@DarianShawn DarianShawn added the bug fix Functionality that fixes a bug label Aug 26, 2022
@DarianShawn DarianShawn self-assigned this Aug 26, 2022
Copy link
Collaborator

@abrahamcruise321 abrahamcruise321 left a comment

Choose a reason for hiding this comment

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

lgtm.

@abrahamcruise321 abrahamcruise321 merged commit b1cf194 into dev Aug 26, 2022
@abrahamcruise321 abrahamcruise321 deleted the fix/ws-timeout-filter-not-removed branch August 26, 2022 07:14
@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix Functionality that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants