vtctl: WaitForFilteredReplication no longer requires a "Target" message in the StreamHealthResponse.

Unfortunately, "Target" is not set in SqlQuery for the destination master during resharding because its QueryService state is "not serving".

Therefore, the health check does not include the "Target".

I've removed the "Target" check for now to unblock the automation task.

However, I think we should fix this and untangle the "Target" in SqlQuery from the serving state respectively the healthcheck.
This commit is contained in:
Michael Berlin 2015-08-18 17:26:19 -07:00
Родитель 2fb9e68dad
Коммит db7daa47a1
3 изменённых файлов: 4 добавлений и 38 удалений

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

@ -119,11 +119,6 @@ func NewSqlQuery(config Config) *SqlQuery {
return sq
}
// SetTargetForTest allows to modify the target without calling allowQueries.
func (sq *SqlQuery) SetTargetForTest(target *pb.Target) {
sq.target = target
}
// GetState returns the name of the current SqlQuery state.
func (sq *SqlQuery) GetState() string {
sq.mu.Lock()

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

@ -1388,16 +1388,6 @@ func commandWaitForFilteredReplication(ctx context.Context, wr *wrangler.Wrangle
if !ok {
return fmt.Errorf("stream ended early: %v", errFunc())
}
gotTarget := shr.Target
if gotTarget == nil {
return fmt.Errorf("stream health record did not include Target: %v", shr)
}
if gotTarget.Keyspace != keyspace || gotTarget.Shard != shard {
return fmt.Errorf("received health record for wrong tablet. Expected tablet: %v/%v received health record: %v", keyspace, shard, shr)
}
if gotTarget.TabletType != pb.TabletType_MASTER {
return fmt.Errorf("tablet: %v should be master, but is not. type: %v", alias, gotTarget.TabletType.String())
}
delaySecs := shr.RealtimeStats.SecondsBehindMasterFilteredReplication
lastSeenDelay := time.Duration(delaySecs) * time.Second

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

@ -31,28 +31,10 @@ const destShard = "-80"
// WaitForFilteredReplication ensures that the dest shard has caught up
// with the source shard up to a maximum replication delay (in seconds).
func TestWaitForFilteredReplication(t *testing.T) {
target := &pbq.Target{Keyspace: keyspace, Shard: destShard, TabletType: pbt.TabletType_MASTER}
waitForFilteredReplicationDefaultDelay(t, target, "" /* expectedErr */)
waitForFilteredReplicationDefaultDelay(t, "" /* expectedErr */)
}
// TestWaitForFilteredReplication_nonMasterFails tests that
// vtctl WaitForFilteredReplication fails if the queried tablet is not MASTER.
func TestWaitForFilteredReplication_nonMasterFails(t *testing.T) {
target := &pbq.Target{Keyspace: keyspace, Shard: destShard, TabletType: pbt.TabletType_REPLICA}
waitForFilteredReplicationDefaultDelay(t, target, "should be master, but is not")
}
// TestWaitForFilteredReplication_wrongTarget tests that
// vtctl WaitForFilteredReplication fails if the target is different than expected.
func TestWaitForFilteredReplication_wrongTarget(t *testing.T) {
target := &pbq.Target{Keyspace: keyspace, Shard: "wrongshard", TabletType: pbt.TabletType_MASTER}
waitForFilteredReplicationDefaultDelay(t, target, "received health record for wrong tablet")
}
func waitForFilteredReplicationDefaultDelay(t *testing.T, target *pbq.Target, expectedErr string) {
func waitForFilteredReplicationDefaultDelay(t *testing.T, expectedErr string) {
// Replication is lagging behind.
oneHourDelay := &pbq.RealtimeStats{
SecondsBehindMasterFilteredReplication: 3600,
@ -65,10 +47,10 @@ func waitForFilteredReplicationDefaultDelay(t *testing.T, target *pbq.Target, ex
}
}
waitForFilteredReplication(t, target, expectedErr, oneHourDelay, oneSecondDelayFunc)
waitForFilteredReplication(t, expectedErr, oneHourDelay, oneSecondDelayFunc)
}
func waitForFilteredReplication(t *testing.T, target *pbq.Target, expectedErr string, initialStats *pbq.RealtimeStats, broadcastStatsFunc func() *pbq.RealtimeStats) {
func waitForFilteredReplication(t *testing.T, expectedErr string, initialStats *pbq.RealtimeStats, broadcastStatsFunc func() *pbq.RealtimeStats) {
ts := zktopo.NewTestServer(t, []string{"cell1", "cell2"})
wr := wrangler.New(logutil.NewConsoleLogger(), ts, tmclient.NewTabletManagerClient(), time.Second)
vp := NewVtctlPipe(t, ts)
@ -92,7 +74,6 @@ func waitForFilteredReplication(t *testing.T, target *pbq.Target, expectedErr st
testConfig.EnablePublishStats = false
testConfig.DebugURLPrefix = fmt.Sprintf("TestWaitForFilteredReplication-%d-", rand.Int63())
qs := tabletserver.NewSqlQuery(testConfig)
qs.SetTargetForTest(target)
grpcqueryservice.RegisterForTest(dest.RPCServer, qs)
qs.BroadcastHealth(42, initialStats)