Skip to content

Commit

Permalink
Support specifying CurrentPrimary in ERS
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Aug 26, 2024
1 parent a54d5ec commit c9c914a
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 175 deletions.
364 changes: 189 additions & 175 deletions go/vt/proto/vtctldata/vtctldata.pb.go

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions go/vt/proto/vtctldata/vtctldata_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,7 @@ func (s *VtctldServer) EmergencyReparentShard(ctx context.Context, req *vtctldat
WaitReplicasTimeout: waitReplicasTimeout,
WaitAllTablets: req.WaitForAllTablets,
PreventCrossCellPromotion: req.PreventCrossCellPromotion,
CurrentPrimaryAlias: req.CurrentPrimary,
},
)

Expand Down
5 changes: 5 additions & 0 deletions go/vt/vtctl/reparentutil/emergency_reparenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type EmergencyReparentOptions struct {
WaitAllTablets bool
WaitReplicasTimeout time.Duration
PreventCrossCellPromotion bool
CurrentPrimaryAlias *topodatapb.TabletAlias

// Private options managed internally. We use value passing to avoid leaking
// these details back out.
Expand Down Expand Up @@ -165,6 +166,10 @@ func (erp *EmergencyReparenter) reparentShardLocked(ctx context.Context, ev *eve
}
ev.ShardInfo = *shardInfo

if opts.CurrentPrimaryAlias != nil && opts.CurrentPrimaryAlias != shardInfo.PrimaryAlias {
return vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "CurrentPrimary %q is not equal to %q", shardInfo.PrimaryAlias, opts.CurrentPrimaryAlias)
}

keyspaceDurability, err := erp.ts.GetKeyspaceDurability(ctx, keyspace)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions proto/vtctldata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ message EmergencyReparentShardRequest {
// WaitForAllTablets makes ERS wait for a response from all the tablets before proceeding.
// Useful when all the tablets are up and reachable.
bool wait_for_all_tablets = 7;
// CurrentPrimary is the alias we expect to be the current primary.
topodata.TabletAlias current_primary = 8;
}

message EmergencyReparentShardResponse {
Expand Down
6 changes: 6 additions & 0 deletions web/vtadmin/src/proto/vtadmin.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions web/vtadmin/src/proto/vtadmin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c9c914a

Please sign in to comment.