Skip to content

Commit

Permalink
Add logs to .Get methods
Browse files Browse the repository at this point in the history
  • Loading branch information
aadi-shopify committed Oct 10, 2024
1 parent ff8fdc5 commit b6e9789
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions go/vt/topo/cell_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"

"vitess.io/vitess/go/sets"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/vterrors"

topodatapb "vitess.io/vitess/go/vt/proto/topodata"
Expand Down Expand Up @@ -70,6 +71,7 @@ func (ts *Server) GetCellInfo(ctx context.Context, cell string, strongRead bool)
filePath := pathForCellInfo(cell)
contents, _, err := conn.Get(ctx, filePath)
if err != nil {
log.Warningf("GetCellInfo failed for cell %s: %v", cell, err)
return nil, err
}

Expand Down Expand Up @@ -115,6 +117,7 @@ func (ts *Server) UpdateCellInfoFields(ctx context.Context, cell string, update
case IsErrType(err, NoNode):
// Nothing to do.
default:
log.Warningf("GetCellInfo failed for cell %s: %v", cell, err)
return err
}

Expand Down
4 changes: 4 additions & 0 deletions go/vt/topo/cells_aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"context"

"vitess.io/vitess/go/vt/log"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

Expand Down Expand Up @@ -56,6 +57,7 @@ func (ts *Server) GetCellsAliases(ctx context.Context, strongRead bool) (ret map
aliasPath := pathForCellsAlias(alias)
contents, _, err := conn.Get(ctx, aliasPath)
if err != nil {
log.Warningf("GetCellsAliases failed for alias %s: %v", alias, err)
return nil, err
}

Expand Down Expand Up @@ -83,6 +85,7 @@ func (ts *Server) GetCellsAlias(ctx context.Context, name string, strongRead boo
aliasPath := pathForCellsAlias(name)
contents, _, err := conn.Get(ctx, aliasPath)
if err != nil {
log.Warningf("GetCellsAlias failed for alias %s: %v", name, err)
return nil, err
}

Expand Down Expand Up @@ -146,6 +149,7 @@ func (ts *Server) UpdateCellsAlias(ctx context.Context, alias string, update fun
case IsErrType(err, NoNode):
// Nothing to do.
default:
log.Warningf("GetCellsAlias failed for alias %s: %v", alias, err)
return err
}

Expand Down
2 changes: 2 additions & 0 deletions go/vt/topo/external_vitess_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"path"

"vitess.io/vitess/go/event"
"vitess.io/vitess/go/vt/log"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
"vitess.io/vitess/go/vt/topo/events"
"vitess.io/vitess/go/vt/vterrors"
Expand Down Expand Up @@ -72,6 +73,7 @@ func (ts *Server) GetExternalVitessCluster(ctx context.Context, clusterName stri
return nil, nil
case err == nil:
default:
log.Warningf("GetExternalVitessCluster failed for cluster %s: %v", clusterName, err)
return nil, err
}
vc := &topodatapb.ExternalVitessCluster{}
Expand Down
1 change: 1 addition & 0 deletions go/vt/topo/keyspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (ts *Server) GetKeyspace(ctx context.Context, keyspace string) (*KeyspaceIn
keyspacePath := path.Join(KeyspacesPath, keyspace, KeyspaceFile)
data, version, err := ts.globalCell.Get(ctx, keyspacePath)
if err != nil {
log.Warningf("GetKeyspace failed for keyspace %s: %v", keyspace, err)
return nil, err
}

Expand Down
3 changes: 3 additions & 0 deletions go/vt/topo/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"path"

"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sqlparser"

"vitess.io/vitess/go/event"
Expand All @@ -35,6 +36,7 @@ func (ts *Server) UpsertMetadata(ctx context.Context, key string, val string) er

if err != nil {
if !IsErrType(err, NoNode) {
log.Warningf("UpsertMetadata failed for key %s: %v", key, err)
return err
}

Expand Down Expand Up @@ -92,6 +94,7 @@ func (ts *Server) getMetadata(ctx context.Context, key string) (string, error) {
keyPath := path.Join(MetadataPath, key)
contents, _, err := ts.globalCell.Get(ctx, keyPath)
if err != nil {
log.Warningf("getMetadata failed for key %s: %v", key, err)
return "", err
}

Expand Down
2 changes: 2 additions & 0 deletions go/vt/topo/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func (ts *Server) UpdateShardReplicationFields(ctx context.Context, cell, keyspa
return vterrors.Wrap(err, "bad ShardReplication data")
}
default:
log.Warningf("GetShardReplication failed for cell %s, keyspace %s, shard %s: %v", cell, keyspace, shard, err)
return err
}

Expand Down Expand Up @@ -239,6 +240,7 @@ func (ts *Server) GetShardReplication(ctx context.Context, cell, keyspace, shard
nodePath := path.Join(KeyspacesPath, keyspace, ShardsPath, shard, ShardReplicationFile)
data, _, err := conn.Get(ctx, nodePath)
if err != nil {
log.Warningf("GetShardReplication failed for cell %s, keyspace %s, shard %s: %v", cell, keyspace, shard, err)
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion go/vt/topo/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ func (ts *Server) GetShard(ctx context.Context, keyspace, shard string) (*ShardI
shardPath := shardFilePath(keyspace, shard)

data, version, err := ts.globalCell.Get(ctx, shardPath)

if err != nil {
log.Warningf("GetShard failed for keyspace %s, shard %s: %v", keyspace, shard, err)
return nil, err
}

Expand Down
2 changes: 2 additions & 0 deletions go/vt/topo/srv_keyspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"path"
"sync"

"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/vterrors"

"vitess.io/vitess/go/vt/concurrency"
Expand Down Expand Up @@ -686,6 +687,7 @@ func (ts *Server) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*t
nodePath := srvKeyspaceFileName(keyspace)
data, _, err := conn.Get(ctx, nodePath)
if err != nil {
log.Warningf("GetSrvKeyspace failed for cell %s, keyspace %s: %v", cell, keyspace, err)
return nil, err
}
srvKeyspace := &topodatapb.SrvKeyspace{}
Expand Down
1 change: 1 addition & 0 deletions go/vt/topo/srv_vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (ts *Server) GetSrvVSchema(ctx context.Context, cell string) (*vschemapb.Sr
nodePath := SrvVSchemaFile
data, _, err := conn.Get(ctx, nodePath)
if err != nil {
log.Warningf("GetSrvVSchema failed for cell %s: %v", cell, err)
return nil, err
}
srvVSchema := &vschemapb.SrvVSchema{}
Expand Down
2 changes: 2 additions & 0 deletions go/vt/topo/stats_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

"vitess.io/vitess/go/stats"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/vterrors"
)
Expand Down Expand Up @@ -109,6 +110,7 @@ func (st *StatsConn) Get(ctx context.Context, filePath string) ([]byte, Version,
defer topoStatsConnTimings.Record(statsKey, startTime)
bytes, version, err := st.conn.Get(ctx, filePath)
if err != nil {
log.Warningf("Get failed for cell %s, filePath %s: %v", st.cell, filePath, err)
topoStatsConnErrors.Add(statsKey, int64(1))
return bytes, version, err
}
Expand Down
3 changes: 3 additions & 0 deletions go/vt/topo/vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (ts *Server) GetVSchema(ctx context.Context, keyspace string) (*vschemapb.K
nodePath := path.Join(KeyspacesPath, keyspace, VSchemaFile)
data, _, err := ts.globalCell.Get(ctx, nodePath)
if err != nil {
log.Warningf("GetVSchema failed for keyspace %s: %v", keyspace, err)
return nil, err
}
var vs vschemapb.Keyspace
Expand Down Expand Up @@ -115,6 +116,7 @@ func (ts *Server) GetRoutingRules(ctx context.Context) (*vschemapb.RoutingRules,
if IsErrType(err, NoNode) {
return rr, nil
}
log.Warningf("GetRoutingRules failed for cell %s: %v", ts.globalCell, err)
return nil, err
}
err = rr.UnmarshalVT(data)
Expand Down Expand Up @@ -150,6 +152,7 @@ func (ts *Server) GetShardRoutingRules(ctx context.Context) (*vschemapb.ShardRou
if IsErrType(err, NoNode) {
return srr, nil
}
log.Warningf("GetShardRoutingRules failed for cell %s: %v", ts.globalCell, err)
return nil, err
}
err = srr.UnmarshalVT(data)
Expand Down
1 change: 1 addition & 0 deletions go/vt/topo/wildcards.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,6 @@ func (ts *Server) resolveRecursive(ctx context.Context, cell string, parts []str
// The path doesn't exist, don't return anything.
return nil, nil
}
log.Warningf("Get failed for cell %s, filePath %s: %v", cell, p, err)
return nil, err
}
2 changes: 2 additions & 0 deletions go/vt/topo/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"context"

"vitess.io/vitess/go/vt/log"
workflowpb "vitess.io/vitess/go/vt/proto/workflow"
)

Expand Down Expand Up @@ -83,6 +84,7 @@ func (ts *Server) GetWorkflow(ctx context.Context, uuid string) (*WorkflowInfo,
filePath := pathForWorkflow(uuid)
contents, version, err := ts.globalCell.Get(ctx, filePath)
if err != nil {
log.Warningf("GetWorkflow failed for cell %s, filePath %s: %v", ts.globalCell, filePath, err)
return nil, err
}

Expand Down

0 comments on commit b6e9789

Please sign in to comment.