hashicorp / hashicorp/consul

Gracefully handle panics in all request handlers

Open
#10,715 2 comments 0 reactions 0 assignees View on GitHub
theme/reliability
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
1d 18h
Merged PRs (30d)
39

Description

[http.Server](https://pkg.go.dev/net/http#Server) handles panics in request handler goroutines using `recover`, but other servers used by Consul do not. By handling panics in request handlers we will prevent any panics in request handlers from shutting down the entire process.

* [x] HTTP API should already work correctly because `http.Server` handles panics
* [x] #10895 XDS `grpc.Server` can use [grpc-middleware/recover](https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware/v2@v2.0.0-rc.2/interceptors/recovery) (or an interceptor with a similar implementation)
* [x] #10895 Server RPC `grpc.Server` can use the same
* [ ] the Server port has [many services behind it](https://github.com/hashicorp/consul/tree/main/contributing/rpc#routing). `Server.handleConsulConn` can recover from most, but we should also look at `Server.handleSnapshotConn` and `Server.handleInsecureConn` and probably do the same there.
* [ ] DNS interface - unknown. needs investigation

Contributor guide

Open the contributing guide

Research direction

Start with Server.handleSnapshotConn and Server.handleInsecureConn, alongside the existing Server.handleConsulConn recovery path. Investigate the DNS interface separately, then verify that all request-handler paths recover panics without shutting down the process; the issue does not identify a test file.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, grpc
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.