Skip to content

Commit

Permalink
Remove legacy healthcheck files and structures (#10542)
Browse files Browse the repository at this point in the history
* Changed the txthrottler to use the new healthcheck implementation

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Removed the use of the legacy healthcheck in the tx_throttler

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Started the removal of the legacy healthcheck in vtworker

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Remove the legacy healthcheck from vtworker

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Remove the legacy healthcheck from vtworker

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Remove the legacy healthcheck from the wrangler

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Remove the legacy healthcheck and al. files

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Applied goimports and linter on the throttler package

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Fixed build issue and code comments

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Fixed comment of GetTabletStats

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Removed duplicated function GetTabletStats

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Reverted the changes to throttler.Result

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Use GetHealthyTabletStats in waitForDrainInCell and removed unrequired target.shard checks

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Addition of a NewCellTabletsWatcher to waitForDrainInCell

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>

* Moved TabletRecorded methods inside the HealthCheck interface

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui authored Jul 8, 2022
1 parent 3256526 commit da6f297
Show file tree
Hide file tree
Showing 37 changed files with 377 additions and 4,416 deletions.
238 changes: 0 additions & 238 deletions go/vt/discovery/fake_legacy_healthcheck.go

This file was deleted.

45 changes: 28 additions & 17 deletions go/vt/discovery/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"time"

"vitess.io/vitess/go/flagutil"
"vitess.io/vitess/go/netutil"
"vitess.io/vitess/go/stats"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/proto/query"
Expand Down Expand Up @@ -81,12 +82,15 @@ var (
refreshKnownTablets = flag.Bool("tablet_refresh_known_tablets", true, "tablet refresh reloads the tablet address/port map from topo in case it changes")
// topoReadConcurrency tells us how many topo reads are allowed in parallel
topoReadConcurrency = flag.Int("topo_read_concurrency", 32, "concurrent topo reads")

// How much to sleep between each check.
waitAvailableTabletInterval = 100 * time.Millisecond
)

// See the documentation for NewHealthCheck below for an explanation of these parameters.
const (
defaultHealthCheckRetryDelay = 5 * time.Second
defaultHealthCheckTimeout = 1 * time.Minute
DefaultHealthCheckRetryDelay = 5 * time.Second
DefaultHealthCheckTimeout = 1 * time.Minute

// DefaultTopoReadConcurrency is used as the default value for the topoReadConcurrency parameter of a TopologyWatcher.
DefaultTopoReadConcurrency int = 5
Expand Down Expand Up @@ -150,22 +154,20 @@ func FilteringKeyspaces() bool {
return len(KeyspacesToWatch) > 0
}

// TabletRecorder is a sub interface of HealthCheck.
// It is separated out to enable unit testing.
type TabletRecorder interface {
type KeyspaceShardTabletType string
type tabletAliasString string

// HealthCheck declares what the TabletGateway needs from the HealthCheck
type HealthCheck interface {
// AddTablet adds the tablet.
AddTablet(tablet *topodata.Tablet)

// RemoveTablet removes the tablet.
RemoveTablet(tablet *topodata.Tablet)

// ReplaceTablet does an AddTablet and RemoveTablet in one call, effectively replacing the old tablet with the new.
ReplaceTablet(old, new *topodata.Tablet)
}

type KeyspaceShardTabletType string
type tabletAliasString string

// HealthCheck declares what the TabletGateway needs from the HealthCheck
type HealthCheck interface {
// CacheStatus returns a displayable version of the health check cache.
CacheStatus() TabletsCacheStatusList

Expand Down Expand Up @@ -619,17 +621,14 @@ func (hc *HealthCheckImpl) GetHealthyTabletStats(target *query.Target) []*Tablet
var result []*TabletHealth
hc.mu.Lock()
defer hc.mu.Unlock()
if target.Shard == "" {
target.Shard = "0"
}
return append(result, hc.healthy[KeyFromTarget(target)]...)
}

// getTabletStats returns all tablets for the given target.
// GetTabletStats returns all tablets for the given target.
// The returned array is owned by the caller.
// For TabletType_PRIMARY, this will only return at most one entry,
// the most recent tablet of type primary.
func (hc *HealthCheckImpl) getTabletStats(target *query.Target) []*TabletHealth {
func (hc *HealthCheckImpl) GetTabletStats(target *query.Target) []*TabletHealth {
var result []*TabletHealth
hc.mu.Lock()
defer hc.mu.Unlock()
Expand Down Expand Up @@ -698,7 +697,7 @@ func (hc *HealthCheckImpl) waitForTablets(ctx context.Context, targets []*query.
if requireServing {
tabletHealths = hc.GetHealthyTabletStats(target)
} else {
tabletHealths = hc.getTabletStats(target)
tabletHealths = hc.GetTabletStats(target)
}
if len(tabletHealths) == 0 {
allPresent = false
Expand Down Expand Up @@ -899,3 +898,15 @@ func (hc *HealthCheckImpl) stateChecksum() int64 {

return int64(crc32.ChecksumIEEE(buf.Bytes()))
}

// TabletToMapKey creates a key to the map from tablet's host and ports.
// It should only be used in discovery and related module.
func TabletToMapKey(tablet *topodata.Tablet) string {
parts := make([]string, 0, 1)
for name, port := range tablet.PortMap {
parts = append(parts, netutil.JoinHostPort(name, port))
}
sort.Strings(parts)
parts = append([]string{tablet.Hostname}, parts...)
return strings.Join(parts, ",")
}
Loading

0 comments on commit da6f297

Please sign in to comment.