Skip to content

Commit

Permalink
Filter out vrepl tables
Browse files Browse the repository at this point in the history
  • Loading branch information
notfelineit committed Aug 9, 2024
1 parent 910fcb8 commit cd2ad93
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/internal/planetscale_edge_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"database/sql"
"fmt"
"github.com/pkg/errors"
"regexp"
"strings"
"time"

"github.com/pkg/errors"
)

type VitessTablet struct {
Expand Down Expand Up @@ -111,10 +112,12 @@ func (p planetScaleEdgeMySQLAccess) PingContext(ctx context.Context, psc PlanetS
}

const (
gCTableNameExpression string = `^_vt_(HOLD|PURGE|EVAC|DROP)_([0-f]{32})_([0-9]{14})$`
gCTableNameExpression string = `^_vt_(HOLD|PURGE|EVAC|DROP)_([0-f]{32})_([0-9]{14})$`
vreplTableNameExpression string = `\b_(\w+|\d+)_\d+_vrepl\b`
)

var gcTableNameRegexp = regexp.MustCompile(gCTableNameExpression)
var vreplRegex = regexp.MustCompile(vreplTableNameExpression)

func (p planetScaleEdgeMySQLAccess) GetTableNames(ctx context.Context, psc PlanetScaleSource) ([]string, error) {
var tables []string
Expand All @@ -131,7 +134,7 @@ func (p planetScaleEdgeMySQLAccess) GetTableNames(ctx context.Context, psc Plane
}

// skip any that are Vitess's GC tables.
if !gcTableNameRegexp.MatchString(name) {
if !gcTableNameRegexp.MatchString(name) && !vreplRegex.MatchString(name) {
tables = append(tables, name)
}
}
Expand Down

0 comments on commit cd2ad93

Please sign in to comment.