Skip to content

Commit

Permalink
Only throttle some logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurschreiber committed Jul 9, 2024
1 parent 05947e3 commit f522700
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions go/vt/vttablet/grpctabletconn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/callerid"
"vitess.io/vitess/go/vt/grpcclient"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/vttablet/queryservice"
Expand Down Expand Up @@ -82,7 +83,7 @@ type gRPCQueryClient struct {
c queryservicepb.QueryClient
}

var logger = logutil.NewThrottledLogger("gRPCQueryClient", 50*time.Millisecond)
var throttledLogger = logutil.NewThrottledLogger("gRPCQueryClient", 50*time.Millisecond)

var _ queryservice.QueryService = (*gRPCQueryClient)(nil)

Expand Down Expand Up @@ -119,7 +120,7 @@ func (conn *gRPCQueryClient) Execute(ctx context.Context, target *querypb.Target
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (alias: %v, type: )", conn.tablet.Alias, conn.tablet.Type)
throttledLogger.Errorf("vttablet: Connection Closed (alias: %v, type: )", conn.tablet.Alias, conn.tablet.Type)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -159,7 +160,7 @@ func (conn *gRPCQueryClient) StreamExecute(ctx context.Context, target *querypb.
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -428,7 +429,7 @@ func (conn *gRPCQueryClient) ReadTransaction(ctx context.Context, target *queryp
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet.Alias)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet.Alias)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -494,7 +495,7 @@ func (conn *gRPCQueryClient) BeginStreamExecute(ctx context.Context, target *que
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -567,7 +568,7 @@ func (conn *gRPCQueryClient) MessageStream(ctx context.Context, target *querypb.
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -635,7 +636,7 @@ func (conn *gRPCQueryClient) StreamHealth(ctx context.Context, callback func(*qu
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -671,7 +672,7 @@ func (conn *gRPCQueryClient) VStream(ctx context.Context, request *binlogdatapb.
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -720,7 +721,7 @@ func (conn *gRPCQueryClient) VStreamRows(ctx context.Context, request *binlogdat
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -766,7 +767,7 @@ func (conn *gRPCQueryClient) VStreamResults(ctx context.Context, target *querypb
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -855,7 +856,7 @@ func (conn *gRPCQueryClient) ReserveBeginStreamExecute(ctx context.Context, targ
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -970,7 +971,7 @@ func (conn *gRPCQueryClient) ReserveStreamExecute(ctx context.Context, target *q
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -1067,7 +1068,7 @@ func (conn *gRPCQueryClient) GetSchema(ctx context.Context, target *querypb.Targ
conn.mu.RLock()
defer conn.mu.RUnlock()
if conn.cc == nil {
logger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
throttledLogger.Errorf("vttablet: Connection Closed (%v)", conn.tablet)
return nil, tabletconn.ConnClosed
}

Expand Down Expand Up @@ -1106,7 +1107,7 @@ func (conn *gRPCQueryClient) Close(ctx context.Context) error {
return nil
}

logger.Infof("vttablet: Closing Connection (%v)", conn.tablet)
log.Infof("vttablet: Closing Connection (%v)", conn.tablet)

cc := conn.cc
conn.cc = nil
Expand Down

0 comments on commit f522700

Please sign in to comment.