-
Notifications
You must be signed in to change notification settings - Fork 44
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: Handle panics in the rpc server #1330
Conversation
go.mod
Outdated
@@ -87,6 +87,7 @@ require ( | |||
github.com/google/gopacket v1.1.19 // indirect | |||
github.com/google/pprof v0.0.0-20221203041831-ce31453925ec // indirect | |||
github.com/google/uuid v1.3.0 // indirect | |||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect |
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.
todo: Don't think this should be indirect. Try running make tidy
.
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.
good spot - thanks Shahzad - I think I'm guilty of skimming over this file :)
- make tidy
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.
You're right Shahzad. This probably needs to change.
Codecov Report
@@ Coverage Diff @@
## develop #1330 +/- ##
===========================================
+ Coverage 70.52% 70.60% +0.08%
===========================================
Files 184 184
Lines 17792 17801 +9
===========================================
+ Hits 12547 12568 +21
+ Misses 4286 4278 -8
+ Partials 959 955 -4
|
1855f92
to
9b30b7a
Compare
MaxConnectionIdle: rpcTimeoutDuration, | ||
})) | ||
server := grpc.NewServer( | ||
grpc.UnaryInterceptor( |
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.
question: What was the reason for Unary over Stream?
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.
I believe it would be because we don't use rpc streaming.
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.
was easy to test that - I had no idea which one we used and added the streaming one first - to no effect on the CLI. If we end up using it at some point we can add in the middleware for it then IMO
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.
Thanks for the explanation :)
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.
LGTM, thanks for doing make tidy
. Got one question for you.
@@ -20,6 +20,8 @@ import ( | |||
"strings" | |||
|
|||
badger "github.com/dgraph-io/badger/v3" | |||
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" |
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.
todo: If you don't mind, there is v2 that is now available. We should probably use that instead.
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.
V2 is not released yet (pre-release build only)
MaxConnectionIdle: rpcTimeoutDuration, | ||
})) | ||
server := grpc.NewServer( | ||
grpc.UnaryInterceptor( |
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.
I believe it would be because we don't use rpc streaming.
requested change is not possible, and I'd like to merge this and another PR before logging off today before the release
Relevant issue(s)
Resolves #1298
Description
Adds middleware to handle panics in the rpc server.
Currently panics via the server will result in the full defradb instance crashing, this PR adds middleware that converts the panics into errors.
Tested by hacking in a panic and calling into the server via the CLI to see if it results in an error or a panic/crash.