Revert "Merge pull request #5203 from systay/never-master"

This reverts commit 2731866eac, reversing
changes made to 698935b636.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
This commit is contained in:
Sugu Sougoumarane 2019-10-06 13:11:54 -07:00
Родитель 2731866eac
Коммит c1dcd4badb
3 изменённых файлов: 0 добавлений и 40 удалений

Просмотреть файл

@ -21,9 +21,6 @@ import (
"sync"
"time"
"vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/vterrors"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"vitess.io/vitess/go/event"
@ -43,18 +40,8 @@ var (
finalizeReparentTimeout = flag.Duration("finalize_external_reparent_timeout", 30*time.Second, "Timeout for the finalize stage of a fast external reparent reconciliation.")
externalReparentStats = stats.NewTimings("ExternalReparents", "External reparenting time", "stage", "NewMasterVisible", "FullRebuild")
neverReparent = flag.Bool("never_reparent", false, "if set to true, this tablet will not become MASTER")
)
// IsItSafeToReparent returns nil if we can reparent, and an error if we shouldn't
func IsItSafeToReparent() error {
if *neverReparent {
return vterrors.New(vtrpc.Code_INVALID_ARGUMENT, "never_reparent set to true, so will not reparent")
}
return nil
}
// SetReparentFlags changes flag values. It should only be used in tests.
func SetReparentFlags(timeout time.Duration) {
*finalizeReparentTimeout = timeout
@ -63,10 +50,6 @@ func SetReparentFlags(timeout time.Duration) {
// TabletExternallyReparented updates all topo records so the current
// tablet is the new master for this shard.
func (agent *ActionAgent) TabletExternallyReparented(ctx context.Context, externalID string) error {
err := IsItSafeToReparent()
if err != nil {
return err
}
if err := agent.lock(ctx); err != nil {
return err
}

Просмотреть файл

@ -19,8 +19,6 @@ package tabletmanager
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTabletExternallyReparentedAlwaysUpdatesTimestamp(t *testing.T) {
@ -45,13 +43,3 @@ func TestTabletExternallyReparentedAlwaysUpdatesTimestamp(t *testing.T) {
t.Fatalf("subsequent TER call did not update the timestamp: %v = %v", ter1, ter2)
}
}
func TestShouldNotReparent(t *testing.T) {
ctx := context.Background()
agent := createTestAgent(ctx, t, nil)
soTrue := true
neverReparent = &soTrue
err := agent.TabletExternallyReparented(ctx, "unused_id")
assert.Error(t, err)
}

Просмотреть файл

@ -26,8 +26,6 @@ import (
"sync"
"time"
"vitess.io/vitess/go/vt/vttablet/tabletmanager"
"vitess.io/vitess/go/event"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/sqlescape"
@ -331,10 +329,6 @@ func (wr *Wrangler) initShardMasterLocked(ctx context.Context, ev *events.Repare
// PlannedReparentShard will make the provided tablet the master for the shard,
// when both the current and new master are reachable and in good shape.
func (wr *Wrangler) PlannedReparentShard(ctx context.Context, keyspace, shard string, masterElectTabletAlias, avoidMasterAlias *topodatapb.TabletAlias, waitSlaveTimeout time.Duration) (err error) {
err = tabletmanager.IsItSafeToReparent()
if err != nil {
return err
}
// lock the shard
lockAction := fmt.Sprintf(
"PlannedReparentShard(%v, avoid_master=%v)",
@ -610,11 +604,6 @@ func (wr *Wrangler) chooseNewMaster(
// EmergencyReparentShard will make the provided tablet the master for
// the shard, when the old master is completely unreachable.
func (wr *Wrangler) EmergencyReparentShard(ctx context.Context, keyspace, shard string, masterElectTabletAlias *topodatapb.TabletAlias, waitSlaveTimeout time.Duration) (err error) {
err = tabletmanager.IsItSafeToReparent()
if err != nil {
return err
}
// lock the shard
ctx, unlock, lockErr := wr.ts.LockShard(ctx, keyspace, shard, fmt.Sprintf("EmergencyReparentShard(%v)", topoproto.TabletAliasString(masterElectTabletAlias)))
if lockErr != nil {