Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions go/vt/topo/etcd2topo/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ func (s *Server) newUniqueEphemeralKV(ctx context.Context, cli *clientv3.Client,
// delete the node, so we don't leave an orphan
// node behind for *leaseTTL time.

if _, err := cli.Delete(context.Background(), newKey); err != nil {
log.Error(fmt.Sprintf("cli.Delete(context.Background(), newKey) failed :%v", err))
deleteCtx, deleteCancel := context.WithTimeout(context.WithoutCancel(ctx), topo.RemoteOperationTimeout)
defer deleteCancel()
if _, err := cli.Delete(deleteCtx, newKey); err != nil {
log.Error(fmt.Sprintf("cli.Delete(%v) failed: %v", newKey, err))
}
}
return "", 0, convertError(err, newKey)
Expand Down Expand Up @@ -223,9 +225,11 @@ func (s *Server) lock(ctx context.Context, nodePath, contents string, ttl int) (
if err != nil {
// We had an error waiting on the last node.
// Revoke our lease, this will delete the file.
if _, rerr := s.cli.Revoke(context.Background(), lease.ID); rerr != nil {
revokeCtx, revokeCancel := context.WithTimeout(context.WithoutCancel(ctx), topo.RemoteOperationTimeout)
if _, rerr := s.cli.Revoke(revokeCtx, lease.ID); rerr != nil {
log.Warn(fmt.Sprintf("Revoke(%d) failed, may have left %v behind: %v", lease.ID, key, rerr))
}
revokeCancel()
return nil, err
}
if done {
Expand Down
16 changes: 11 additions & 5 deletions go/vt/vtctl/workflow/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,30 +163,36 @@ func testConcurrentKeyspaceRoutingRulesUpdates(t *testing.T, ctx context.Context
case <-shortCtx.Done():
return
default:
update(t, ts, id)
update(t, shortCtx, ts, id)
}
}
}(i)
}
wg.Wait()
log.Info("All updates completed")
rules, err := ts.GetKeyspaceRoutingRules(ctx)
verifyCtx, verifyCancel := context.WithTimeout(ctx, 10*time.Second)
defer verifyCancel()
rules, err := ts.GetKeyspaceRoutingRules(verifyCtx)
require.NoError(t, err)
require.LessOrEqual(t, concurrency, len(rules.Rules))
}

func update(t *testing.T, ts *topo.Server, id int) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
func update(t *testing.T, ctx context.Context, ts *topo.Server, id int) {
s := fmt.Sprintf("%d_%d", id, rand.IntN(math.MaxInt))
routes := make(map[string]string)
for _, tabletType := range tabletTypeSuffixes {
from := fmt.Sprintf("from%s%s", s, tabletType)
routes[from] = s + tabletType
}
err := updateKeyspaceRoutingRules(ctx, ts, "test", routes)
if ctx.Err() != nil {
return
}
require.NoError(t, err)
got, err := topotools.GetKeyspaceRoutingRules(ctx, ts)
if ctx.Err() != nil {
return
}
require.NoError(t, err)
for _, tabletType := range tabletTypeSuffixes {
from := fmt.Sprintf("from%s%s", s, tabletType)
Expand Down
Loading