-
Notifications
You must be signed in to change notification settings - Fork 714
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
Properly initialize metrics in rpcchainVM #3477
Conversation
8084c21
to
baac6f4
Compare
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.
Left one nit, then this LGTM
vms/rpcchainvm/vm_server.go
Outdated
pluginMetrics := metrics.NewPrefixGatherer() | ||
|
||
bVM, _ := vm.(block.BuildBlockWithContextChainVM) | ||
ssVM, _ := vm.(block.StateSyncableVM) | ||
return &VMServer{ | ||
vmSrv := &VMServer{ | ||
vm: vm, | ||
bVM: bVM, | ||
ssVM: ssVM, | ||
allowShutdown: allowShutdown, | ||
} | ||
|
||
vmSrv.metrics = pluginMetrics |
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.
Can we switch to just inlining this for the smallest diff? ie. add metrics: metrics.NewPrefixGatherer()
as the next line in the struct definition?
e1b1b66
to
c4d28eb
Compare
vms/rpcchainvm/vm_server.go
Outdated
bVM, _ := vm.(block.BuildBlockWithContextChainVM) | ||
ssVM, _ := vm.(block.StateSyncableVM) | ||
return &VMServer{ | ||
vmSrv := &VMServer{ | ||
metrics: pluginMetrics, |
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.
nit: could just be metrics: metrics.NewPrefixGatherer()
Signed-off-by: Yacov Manevich <[email protected]>
c4d28eb
to
d0ac2e2
Compare
This fixes a race condition while initializing an instance of the RPCChainVM that triggered a panic in AvalancheGo prior to this PR:
The path that triggered this bug is registering VMClient (reference held by the chain manager) as a gatherer here during This is called before calling This can trigger a panic because |
Why this should be merged
The RPC chain VM gRPC dispatcher initializes the metrics at
Initialize()
but it doesn't need any input from theInitialize
method's parameters. It's better to initialize the metrics at the construction of the object.This is needed because currently, if the gRPC service is requested to dispatch a gathering of the metrics, it might be that the metrics in the backend is yet to be initialized, and this is a problem.
How this works
Just a refactoring.
How this was tested
CI