From 79d413e3d483f08846a09e88b8308b6c4774a303 Mon Sep 17 00:00:00 2001 From: chengshiwen Date: Sat, 14 Jan 2023 22:11:34 +0800 Subject: [PATCH] avoid panic in processing write shard request and correct the comments in rpc.go --- coordinator/rpc.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/coordinator/rpc.go b/coordinator/rpc.go index d8ef1ef..6b6fb92 100644 --- a/coordinator/rpc.go +++ b/coordinator/rpc.go @@ -4,7 +4,7 @@ import ( "crypto/tls" "encoding/json" "errors" - "fmt" + "log" "net" "time" @@ -24,7 +24,7 @@ import ( //go:generate protoc --gogo_out=. internal/data.proto -// WriteShardRequest represents the a request to write a slice of points to a shard +// WriteShardRequest represents a request to write a slice of points to a shard type WriteShardRequest struct { pb internal.WriteShardRequest } @@ -73,7 +73,7 @@ func (w *WriteShardRequest) AddPoints(points []models.Point) { // A error here means that we create a point higher in the stack that we could // not marshal to a byte slice. If that happens, the endpoint that created that // point needs to be fixed. - panic(fmt.Sprintf("failed to marshal point: `%v`: %v", p, err)) + log.Printf("failed to marshal point: `%v`: %v", p, err) } w.pb.Points = append(w.pb.Points, b) } @@ -100,7 +100,7 @@ func (w *WriteShardRequest) unmarshalPoints() []models.Point { // A error here means that one node created a valid point and sent us an // unparseable version. We could log and drop the point and allow // anti-entropy to resolve the discrepancy, but this shouldn't ever happen. - panic(fmt.Sprintf("failed to parse point: `%v`: %v", string(p), err)) + log.Printf("failed to parse point: `%v`: %v", string(p), err) } points[i] = pt @@ -133,7 +133,7 @@ func (w *WriteShardResponse) UnmarshalBinary(buf []byte) error { return nil } -// ExecuteStatementRequest represents the a request to execute a statement on a node. +// ExecuteStatementRequest represents a request to execute a statement on a node. type ExecuteStatementRequest struct { pb internal.ExecuteStatementRequest } @@ -197,7 +197,7 @@ func (w *ExecuteStatementResponse) UnmarshalBinary(buf []byte) error { return nil } -// TaskManagerStatementRequest represents the a request to execute a task manager statement on a node. +// TaskManagerStatementRequest represents a request to execute a task manager statement on a node. type TaskManagerStatementRequest struct { Statement string } @@ -219,7 +219,7 @@ func (r *TaskManagerStatementRequest) UnmarshalBinary(data []byte) error { return nil } -// TaskManagerStatementResponse represents a response to show shards. +// TaskManagerStatementResponse represents a response to task manager statement request. type TaskManagerStatementResponse struct { Result query.Result Err error @@ -944,7 +944,7 @@ func (r *FieldDimensionsRequest) UnmarshalBinary(data []byte) error { return nil } -// FieldDimensionsResponse represents a response from remote iterator creation. +// FieldDimensionsResponse represents a response from remote fields & dimensions. type FieldDimensionsResponse struct { Fields map[string]influxql.DataType Dimensions map[string]struct{}