diff --git a/go/vt/vtorc/inst/instance_dao.go b/go/vt/vtorc/inst/instance_dao.go index 35b5d11bc95..2edd68847bb 100644 --- a/go/vt/vtorc/inst/instance_dao.go +++ b/go/vt/vtorc/inst/instance_dao.go @@ -158,13 +158,6 @@ func RegisterStats() { }) } -// ReadTopologyInstance collects information on the state of a MySQL -// server and writes the result synchronously to the vtorc -// backend. -func ReadTopologyInstance(tabletAlias string) (*Instance, error) { - return ReadTopologyInstanceBufferable(tabletAlias, nil) -} - // ReadTopologyInstanceBufferable connects to a topology MySQL instance // and collects information on the server and its replication state. // It writes the information retrieved into vtorc's backend. @@ -629,35 +622,6 @@ func ReadInstance(tabletAlias string) (*Instance, bool, error) { return instances[0], true, nil } -// ReadReplicaInstances reads replicas of a given primary -func ReadReplicaInstances(primaryHost string, primaryPort int) ([](*Instance), error) { - condition := ` - source_host = ? - and source_port = ? - ` - return readInstancesByCondition(condition, sqlutils.Args(primaryHost, primaryPort), "") -} - -// ReadReplicaInstancesIncludingBinlogServerSubReplicas returns a list of direct slves including any replicas -// of a binlog server replica -func ReadReplicaInstancesIncludingBinlogServerSubReplicas(primaryHost string, primaryPort int) ([](*Instance), error) { - replicas, err := ReadReplicaInstances(primaryHost, primaryPort) - if err != nil { - return replicas, err - } - for _, replica := range replicas { - replica := replica - if replica.IsBinlogServer() { - binlogServerReplicas, err := ReadReplicaInstancesIncludingBinlogServerSubReplicas(replica.Hostname, replica.Port) - if err != nil { - return replicas, err - } - replicas = append(replicas, binlogServerReplicas...) - } - } - return replicas, err -} - // ReadProblemInstances reads all instances with problems func ReadProblemInstances(keyspace string, shard string) ([](*Instance), error) { condition := ` @@ -1156,43 +1120,6 @@ func SnapshotTopologies() error { return ExecDBWriteFunc(writeFunc) } -// RecordStaleInstanceBinlogCoordinates snapshots the binlog coordinates of instances -func RecordStaleInstanceBinlogCoordinates(tabletAlias string, binlogCoordinates *BinlogCoordinates) error { - args := sqlutils.Args( - tabletAlias, - binlogCoordinates.LogFile, binlogCoordinates.LogPos, - ) - _, err := db.ExecVTOrc(` - delete from - database_instance_stale_binlog_coordinates - where - alias = ? - and ( - binary_log_file != ? - or binary_log_pos != ? - ) - `, - args..., - ) - if err != nil { - log.Error(err) - return err - } - _, err = db.ExecVTOrc(` - insert ignore into - database_instance_stale_binlog_coordinates ( - alias, binary_log_file, binary_log_pos, first_seen - ) - values ( - ?, ?, ?, NOW() - )`, - args...) - if err != nil { - log.Error(err) - } - return err -} - func ExpireStaleInstanceBinlogCoordinates() error { expireSeconds := config.Config.ReasonableReplicationLagSeconds * 2 if expireSeconds < config.StaleInstanceCoordinatesExpireSeconds { diff --git a/go/vt/vtorc/inst/instance_dao_test.go b/go/vt/vtorc/inst/instance_dao_test.go index c6020ec52d8..2346173ab4f 100644 --- a/go/vt/vtorc/inst/instance_dao_test.go +++ b/go/vt/vtorc/inst/instance_dao_test.go @@ -196,53 +196,6 @@ func TestReadInstance(t *testing.T) { } } -// TestReadReplicaInstances is used to test the functionality of ReadReplicaInstances and verify its failure modes and successes. -func TestReadReplicaInstances(t *testing.T) { - tests := []struct { - name string - tabletPort int - replicasLen int - }{ - { - name: "Read success - Multiple replicas", - // This tabletPort corresponds to zone1-0000000101. That is the primary for the data inserted. - // Check initialSQL for more details. - tabletPort: 6714, - replicasLen: 3, - }, { - name: "Unknown tablet", - // This tabletPort corresponds to none of the tablets. - // Check initialSQL for more details. - tabletPort: 343, - replicasLen: 0, - }, { - name: "Read success - No replicas", - // This tabletPort corresponds to zone1-0000000100. That is a replica tablet, with no replicas of its own. - // Check initialSQL for more details. - tabletPort: 6711, - replicasLen: 0, - }, - } - - // Clear the database after the test. The easiest way to do that is to run all the initialization commands again. - defer func() { - db.ClearVTOrcDatabase() - }() - for _, query := range initialSQL { - _, err := db.ExecVTOrc(query) - require.NoError(t, err) - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - - instances, err := ReadReplicaInstances("localhost", tt.tabletPort) - require.NoError(t, err) - require.EqualValues(t, tt.replicasLen, len(instances)) - }) - } -} - // TestReadProblemInstances is used to test the functionality of ReadProblemInstances and verify its failure modes and successes. func TestReadProblemInstances(t *testing.T) { // The test is intended to be used as follows. The initial data is stored into the database. Following this, some specific queries are run that each individual test specifies to get the desired state. diff --git a/go/vt/vtorc/inst/instance_topology_dao.go b/go/vt/vtorc/inst/instance_topology_dao.go deleted file mode 100644 index 67060b184b7..00000000000 --- a/go/vt/vtorc/inst/instance_topology_dao.go +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright 2015 Shlomi Noach, courtesy Booking.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package inst - -// Max concurrency for bulk topology operations -const topologyConcurrency = 128 - -var topologyConcurrencyChan = make(chan bool, topologyConcurrency) - -// ExecuteOnTopology will execute given function while maintaining concurrency limit -// on topology servers. It is safe in the sense that we will not leak tokens. -func ExecuteOnTopology(f func()) { - topologyConcurrencyChan <- true - defer func() { _ = recover(); <-topologyConcurrencyChan }() - f() -} diff --git a/go/vt/vtorc/logic/tablet_discovery.go b/go/vt/vtorc/logic/tablet_discovery.go index cda35b8091c..58c042232ee 100644 --- a/go/vt/vtorc/logic/tablet_discovery.go +++ b/go/vt/vtorc/logic/tablet_discovery.go @@ -36,7 +36,6 @@ import ( "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/topotools" - "vitess.io/vitess/go/vt/vtctl/reparentutil" "vitess.io/vitess/go/vt/vtorc/config" "vitess.io/vitess/go/vt/vtorc/db" "vitess.io/vitess/go/vt/vtorc/inst" @@ -338,38 +337,3 @@ func shardPrimary(keyspace string, shard string) (primary *topodatapb.Tablet, er } return primary, err } - -// restartsReplication restarts the replication on the provided replicaKey. It also sets the correct semi-sync settings when it starts replication -func restartReplication(replicaAlias string) error { - replicaTablet, err := inst.ReadTablet(replicaAlias) - if err != nil { - log.Info("Could not read tablet - %+v", replicaAlias) - return err - } - - primaryTablet, err := shardPrimary(replicaTablet.Keyspace, replicaTablet.Shard) - if err != nil { - log.Info("Could not compute primary for %v/%v", replicaTablet.Keyspace, replicaTablet.Shard) - return err - } - - durabilityPolicy, err := inst.GetDurabilityPolicy(replicaTablet.Keyspace) - if err != nil { - log.Info("Could not read the durability policy for %v/%v", replicaTablet.Keyspace, replicaTablet.Shard) - return err - } - - ctx, cancel := context.WithTimeout(context.Background(), time.Duration(config.Config.WaitReplicasTimeoutSeconds)*time.Second) - defer cancel() - err = tmc.StopReplication(ctx, replicaTablet) - if err != nil { - log.Info("Could not stop replication on %v", replicaAlias) - return err - } - err = tmc.StartReplication(ctx, replicaTablet, reparentutil.IsReplicaSemiSync(durabilityPolicy, primaryTablet, replicaTablet)) - if err != nil { - log.Info("Could not start replication on %v", replicaAlias) - return err - } - return nil -}