Skip to content

Commit

Permalink
makes less verbose CRDB connection balacer
Browse files Browse the repository at this point in the history
moves logged messages for the CockroachDB connection
balancer from Info/Debug to Trace.
  • Loading branch information
vroldanbet committed Jan 15, 2024
1 parent e2fc914 commit 61d1444
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/datastore/crdb/pool/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (p *nodeConnectionBalancer[P, C]) pruneConnections(ctx context.Context) {
if count <= perNodeMax {
continue
}
log.Ctx(ctx).Info().
log.Ctx(ctx).Trace().
Uint32("node", node).
Uint32("poolmaxconns", p.pool.MaxConns()).
Uint32("conncount", count).
Expand All @@ -228,10 +228,10 @@ func (p *nodeConnectionBalancer[P, C]) pruneConnections(ctx context.Context) {
}

for _, c := range healthyConns[node][:numToPrune] {
log.Ctx(ctx).Debug().Str("pool", p.pool.ID()).Uint32("node", node).Msg("pruning connection")
log.Ctx(ctx).Trace().Str("pool", p.pool.ID()).Uint32("node", node).Msg("pruning connection")
p.pool.GC(c.Conn())
}

log.Ctx(ctx).Info().Str("pool", p.pool.ID()).Uint32("node", node).Uint32("prunedCount", numToPrune).Msg("pruned connections")
log.Ctx(ctx).Trace().Str("pool", p.pool.ID()).Uint32("node", node).Uint32("prunedCount", numToPrune).Msg("pruned connections")
}
}
4 changes: 2 additions & 2 deletions internal/datastore/crdb/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (p *RetryPool) GC(conn *pgx.Conn) {
}

func (p *RetryPool) acquireFromDifferentNode(ctx context.Context, nodeID uint32) (*pgxpool.Conn, error) {
log.Ctx(ctx).Info().Uint32("node_id", nodeID).Msg("acquiring a connection from a different node")
log.Ctx(ctx).Trace().Uint32("node_id", nodeID).Msg("acquiring a connection from a different node")
for {
conn, err := p.pool.Acquire(ctx)
if err != nil {
Expand All @@ -342,7 +342,7 @@ func (p *RetryPool) acquireFromDifferentNode(ctx context.Context, nodeID uint32)
conn.Release()
continue
}
log.Ctx(ctx).Info().Uint32("old node id", nodeID).Uint32("new node id", id).Msg("acquired a connection from a different node")
log.Ctx(ctx).Trace().Uint32("old node id", nodeID).Uint32("new node id", id).Msg("acquired a connection from a different node")
return conn, nil
}
}
Expand Down

0 comments on commit 61d1444

Please sign in to comment.