Skip to content

Commit

Permalink
Add log lines
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
  • Loading branch information
rohit-nayak-ps committed May 14, 2024
1 parent e65f861 commit 6b4d6ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go/vt/topotools/routing_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func UpdateKeyspaceRoutingRules(ctx context.Context, ts *topo.Server, reason str
if lockErr != nil {
// If the key does not yet exist then let's create it.
if !topo.IsErrType(lockErr, topo.NoNode) {
log.Warningf("Failed to lock keyspace routing rules: %v", lockErr)
return lockErr
}
rules := make(map[string]string)
Expand All @@ -198,7 +199,9 @@ func UpdateKeyspaceRoutingRules(ctx context.Context, ts *topo.Server, reason str
// This will fail if the key already exists and thus avoids any races here. The first
// writer will win and the others will have to retry. This situation should be very
// rare as we are typically only updating the rules from here on out.
log.Warningf("Creating keyspace routing rules for the first time")
if err := ts.CreateKeyspaceRoutingRules(ctx, buildKeyspaceRoutingRules(&rules)); err != nil {
log.Warningf("Failed to create keyspace routing rules: %v", err)
return err
}
return nil
Expand All @@ -209,6 +212,7 @@ func UpdateKeyspaceRoutingRules(ctx context.Context, ts *topo.Server, reason str
return err
}
if err := update(lockCtx, &rules); err != nil {
log.Warningf("Failed to update keyspace routing rules: %v", err)
return err
}
if err := saveKeyspaceRoutingRulesLocked(lockCtx, ts, rules); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions go/vt/vtctl/workflow/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,10 @@ func updateKeyspaceRoutingRules(ctx context.Context, ts *topo.Server, reason str
// If we were racing with another caller to create the initial routing rules, then
// we can immediately retry the operation.
if !topo.IsErrType(err, topo.NodeExists) {
log.Warningf("failed to update keyspace routing rules, NOT topo.NodeExists: %v", err)
return err
} else {
log.Warningf("failed to update keyspace routing rules, GOT topo.NodeExists, retrying: %v", err)
}
return update()
}
Expand Down

0 comments on commit 6b4d6ec

Please sign in to comment.