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
21 changes: 13 additions & 8 deletions go/vt/topo/consultopo/replication_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,21 @@ func (s *Server) UpdateShardReplicationFields(ctx context.Context, cell, keyspac
if version == nil {
// We have to create, and we catch ErrNodeExists.
_, err = s.Create(ctx, cell, p, data)
if err != topo.ErrNodeExists {
return err
}
} else {
// We have to update, and we catch ErrBadVersion.
_, err = s.Update(ctx, cell, p, data, version)
if err != topo.ErrBadVersion {
return err
if err == topo.ErrNodeExists {
// Node was created by another process, try
// again.
continue
}
return err
}

// We have to update, and we catch ErrBadVersion.
_, err = s.Update(ctx, cell, p, data, version)
if err == topo.ErrBadVersion {
// Node was updated by another process, try again.
continue
}
return err
}
}

Expand Down
21 changes: 13 additions & 8 deletions go/vt/topo/etcd2topo/replication_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ func (s *Server) UpdateShardReplicationFields(ctx context.Context, cell, keyspac
if version == nil {
// We have to create, and we catch ErrNodeExists.
_, err = s.Create(ctx, cell, p, data)
if err != topo.ErrNodeExists {
return err
}
} else {
// We have to update, and we catch ErrBadVersion.
_, err = s.Update(ctx, cell, p, data, version)
if err != topo.ErrBadVersion {
return err
if err == topo.ErrNodeExists {
// Node was created by another process, try
// again.
continue
}
return err
}

// We have to update, and we catch ErrBadVersion.
_, err = s.Update(ctx, cell, p, data, version)
if err == topo.ErrBadVersion {
// Node was updated by another process, try again.
continue
}
return err
}
}

Expand Down
21 changes: 13 additions & 8 deletions go/vt/topo/zk2topo/replication_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,21 @@ func (zs *Server) UpdateShardReplicationFields(ctx context.Context, cell, keyspa
if version == nil {
// We have to create, and we catch ErrNodeExists.
_, err = zs.Create(ctx, cell, zkPath, data)
if err != topo.ErrNodeExists {
return err
}
} else {
// We have to update, and we catch ErrBadVersion.
_, err = zs.Update(ctx, cell, zkPath, data, version)
if err != topo.ErrBadVersion {
return err
if err == topo.ErrNodeExists {
// Node was created by another process, try
// again.
continue
}
return err
}

// We have to update, and we catch ErrBadVersion.
_, err = zs.Update(ctx, cell, zkPath, data, version)
if err == topo.ErrBadVersion {
// Node was updated by another process, try again.
continue
}
return err
}
}

Expand Down