Skip to content

Commit

Permalink
Prefer using REPLICA tablets when selecting vreplication sources (vit…
Browse files Browse the repository at this point in the history
…essio#10040)

* Prefer using REPLICA tablets when selecting vreplication sources

Signed-off-by: Matt Lord <[email protected]>

* Modify tablet type defaults for generic vrepl workflow handler

Signed-off-by: Matt Lord <[email protected]>

* Add in_order support to the v2 workflow code

Signed-off-by: Matt Lord <[email protected]>

* Minor changes after self review

Signed-off-by: Matt Lord <[email protected]>

* Correct primary tablet type filtering in switchReads

Signed-off-by: Matt Lord <[email protected]>

* Consistently use capitalization for tablet types

Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Vilius Okockis <[email protected]>
  • Loading branch information
mattlord authored and DeathBorn committed Apr 12, 2024
1 parent ffa82a2 commit 03bfd5a
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 119 deletions.
7 changes: 1 addition & 6 deletions go/vt/discovery/tablet_picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ type TabletPicker struct {

// NewTabletPicker returns a TabletPicker.
func NewTabletPicker(ts *topo.Server, cells []string, keyspace, shard, tabletTypesStr string) (*TabletPicker, error) {
inOrder := false
if strings.HasPrefix(tabletTypesStr, inOrderHint) {
inOrder = true
tabletTypesStr = tabletTypesStr[len(inOrderHint):]
}
tabletTypes, err := topoproto.ParseTabletTypes(tabletTypesStr)
tabletTypes, inOrder, err := ParseTabletTypesAndOrder(tabletTypesStr)
if err != nil {
return nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "failed to parse list of tablet types: %v", tabletTypesStr)
}
Expand Down
18 changes: 18 additions & 0 deletions go/vt/discovery/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ limitations under the License.

package discovery

import (
"strings"

topodatapb "vitess.io/vitess/go/vt/proto/topodata"
"vitess.io/vitess/go/vt/topo/topoproto"
)

// This file contains helper filter methods to process the unfiltered list of
// tablets returned by LegacyHealthCheck.GetTabletStatsFrom*.
// See also legacy_replicationlag.go for a more sophisicated filter used by vtgate.
Expand All @@ -37,3 +44,14 @@ func RemoveUnhealthyTablets(tabletStatsList []LegacyTabletStats) []LegacyTabletS
}
return result
}

func ParseTabletTypesAndOrder(tabletTypesStr string) ([]topodatapb.TabletType, bool, error) {
inOrder := false
if strings.HasPrefix(tabletTypesStr, inOrderHint) {
inOrder = true
tabletTypesStr = tabletTypesStr[len(inOrderHint):]
}
tabletTypes, err := topoproto.ParseTabletTypes(tabletTypesStr)

return tabletTypes, inOrder, err
}
Loading

0 comments on commit 03bfd5a

Please sign in to comment.