-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fixing multinode state transition logic by register polling subscription in rpc client #14534
fixing multinode state transition logic by register polling subscription in rpc client #14534
Conversation
.changeset/moody-rules-agree.md
Outdated
"chainlink": patch | ||
--- | ||
|
||
- register polling subscription logic in rpc client so when node unhealthy new susbcription will be used |
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.
- register polling subscription logic in rpc client so when node unhealthy new susbcription will be used | |
- register polling subscription to avoid subscription leaking when rpc client gets closed. |
require.NoError(t, rpc.Dial(ctx)) | ||
|
||
ch := make(chan *evmtypes.Head) | ||
_, err := rpc.SubscribeNewHead(tests.Context(t), ch) |
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.
Could you check that the returned subscription is closed?
@@ -6,6 +6,7 @@ import ( | |||
"errors" | |||
"fmt" | |||
"math/big" | |||
_ "net/http/pprof" |
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.
debug artifact
rpc.DisconnectAll() | ||
|
||
// ensure sub is closed | ||
_, ok := <-errCh |
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.
Could you use
select {
<-errCh: // ok
default: fail
}
To return more explicit error instead of tests timeout
@@ -129,7 +129,8 @@ type rpcClient struct { | |||
ws rawclient | |||
http *rawclient | |||
|
|||
stateMu sync.RWMutex // protects state* fields | |||
stateMu sync.RWMutex // protects state* fields | |||
subsSliceMu sync.RWMutex // protects subscription slice |
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 deadlock was caught by my new unit tests, and this fixes it.
Quality Gate passedIssues Measures |
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.
Nice work!
…ion in rpc client (#14534) * polling subscription to be registered * adding changeset * fix Subscribe new head * add test * update changeset * fix lint * fix deadlock and add unit test for http polling sub * update changeset * adding sub closed check and remove import * add unit test coverage for http polling subscribeToHeads * update test * address comments part 1 * clean * part 2 * fix lint * fix lint
Optional WS URL for RPCs to unblock new chain integration. Charry-picks from: smartcontractkit/chainlink#14354 smartcontractkit/chainlink#14373 smartcontractkit/chainlink#14534 smartcontractkit/chainlink#14364 smartcontractkit/chainlink#14929 --------- Co-authored-by: Joe Huang <joe.huang@smartcontract.com>
Optional WS URL for RPCs to unblock new chain integration. Charry-picks from: smartcontractkit/chainlink#14534 smartcontractkit/chainlink#14364 smartcontractkit/chainlink#14929 --------- Co-authored-by: Joe Huang <joe.huang@smartcontract.com> Co-authored-by: Adam Hamrick <adam.hamrick@smartcontract.com> Co-authored-by: Chunkai Yang <matYang@users.noreply.github.com>
Description
SubscribeToFinalizedHeads and SubscribeToHeads won’t abort polling subscription after Close
It could cause clients like HeadTracker to keep using subscriptions to unhealthy RPC despite MultiNode's transitioning to an unhealthy state.
DoD: polling subscription must be registered
Also added a patch for subscribeNewHead when polling is enabled.
Tickets:
BCFR-946(https://smartcontract-it.atlassian.net/browse/BCFR-946