Skip to content

Commit

Permalink
resolved conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Jul 28, 2024
2 parents 7efcd3f + e341f23 commit b6e6823
Show file tree
Hide file tree
Showing 92 changed files with 12,210 additions and 10,868 deletions.
6 changes: 6 additions & 0 deletions changelog/21.0/21.0.0/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- **[Traffic Mirroring](#traffic-mirroring)**
- **[New VTGate Shutdown Behavior](#new-vtgate-shutdown-behavior)**
- **[Tablet Throttler: Multi-Metric support](#tablet-throttler)**
- **[Allow Cross Cell Promotion in PRS](#allow-cross-cell)**

## <a id="major-changes"/>Major Changes

Expand Down Expand Up @@ -96,3 +97,8 @@ Each metric has a factory threshold which can be overridden by the `UpdateThrott
The throttler also supports the catch-all `"all"` app name, and it is thus possible to assign metrics to _all_ apps. Explicit app to metric assignments will override the catch-all configuration.

Metrics are assigned a default _scope_, which could be `self` (isolated to the tablet) or `shard` (max, aka _worst_ value among shard tablets). It is further possible to require a different scope for each metric.

### <a id="allow-cross-cell"/>Allow Cross Cell Promotion in PRS
Up until now if the users wanted to promote a replica in a different cell than the current primary using `PlannedReparentShard`, they had to specify the new primary with the `--new-primary` flag.

We have now added a new flag `--allow-cross-cell-promotion` that lets `PlannedReparentShard` choose a primary in a different cell even if no new primary is provided explicitly.
12 changes: 5 additions & 7 deletions go/cmd/vtctldclient/command/onlineddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ var (
RunE: commandOnlineDDLCancel,
}
OnlineDDLCleanup = &cobra.Command{
Use: "cleanup <keyspace> <uuid>",
Short: "Mark a given schema migration ready for artifact cleanup.",
Use: "cleanup <keyspace> <uuid|all>",
Short: "Mark a given schema migration, or all complete/failed/cancelled migrations, ready for artifact cleanup.",
Example: "OnlineDDL cleanup test_keyspace 82fa54ac_e83e_11ea_96b7_f875a4d24e90",
DisableFlagsInUseLine: true,
Args: cobra.ExactArgs(2),
Expand Down Expand Up @@ -168,12 +168,10 @@ func commandOnlineDDLCancel(cmd *cobra.Command, args []string) error {
}

func commandOnlineDDLCleanup(cmd *cobra.Command, args []string) error {
keyspace := cmd.Flags().Arg(0)
uuid := cmd.Flags().Arg(1)
if !schema.IsOnlineDDLUUID(uuid) {
return fmt.Errorf("%s is not a valid UUID", uuid)
keyspace, uuid, err := analyzeOnlineDDLCommandWithUuidOrAllArgument(cmd)
if err != nil {
return err
}

cli.FinishedParsing(cmd)

resp, err := client.CleanupSchemaMigration(commandCtx, &vtctldatapb.CleanupSchemaMigrationRequest{
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/vtctldclient/command/reparents.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ var plannedReparentShardOptions = struct {
AvoidPrimaryAliasStr string
WaitReplicasTimeout time.Duration
TolerableReplicationLag time.Duration
AllowCrossCellPromotion bool
}{}

func commandPlannedReparentShard(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -223,6 +224,7 @@ func commandPlannedReparentShard(cmd *cobra.Command, args []string) error {
AvoidPrimary: avoidPrimaryAlias,
WaitReplicasTimeout: protoutil.DurationToProto(plannedReparentShardOptions.WaitReplicasTimeout),
TolerableReplicationLag: protoutil.DurationToProto(plannedReparentShardOptions.TolerableReplicationLag),
AllowCrossCellPromotion: plannedReparentShardOptions.AllowCrossCellPromotion,
})
if err != nil {
return err
Expand Down Expand Up @@ -297,6 +299,7 @@ func init() {
PlannedReparentShard.Flags().DurationVar(&plannedReparentShardOptions.TolerableReplicationLag, "tolerable-replication-lag", 0, "Amount of replication lag that is considered acceptable for a tablet to be eligible for promotion when Vitess makes the choice of a new primary.")
PlannedReparentShard.Flags().StringVar(&plannedReparentShardOptions.NewPrimaryAliasStr, "new-primary", "", "Alias of a tablet that should be the new primary.")
PlannedReparentShard.Flags().StringVar(&plannedReparentShardOptions.AvoidPrimaryAliasStr, "avoid-primary", "", "Alias of a tablet that should not be the primary; i.e. \"reparent to any other tablet if this one is the primary\".")
PlannedReparentShard.Flags().BoolVar(&plannedReparentShardOptions.AllowCrossCellPromotion, "allow-cross-cell-promotion", false, "Allow cross cell promotion")
Root.AddCommand(PlannedReparentShard)

Root.AddCommand(ReparentTablet)
Expand Down
3 changes: 3 additions & 0 deletions go/mysql/binlog/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const (
// TypeTime2 is MYSQL_TYPE_TIME2
TypeTime2 = 19

// TypeVector is MYSQL_TYPE_VECTOR
TypeVector = 242

// TypeJSON is MYSQL_TYPE_JSON
TypeJSON = 245

Expand Down
6 changes: 3 additions & 3 deletions go/mysql/binlog/rbr.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func CellLength(data []byte, pos int, typ byte, metadata uint16) (int, error) {
return intg0*4 + dig2bytes[intg0x] + frac0*4 + dig2bytes[frac0x], nil
case TypeEnum, TypeSet:
return int(metadata & 0xff), nil
case TypeJSON, TypeTinyBlob, TypeMediumBlob, TypeLongBlob, TypeBlob, TypeGeometry:
case TypeJSON, TypeTinyBlob, TypeMediumBlob, TypeLongBlob, TypeBlob, TypeGeometry, TypeVector:
// Of the Blobs, only TypeBlob is used in binary logs,
// but supports others just in case.
switch metadata {
Expand Down Expand Up @@ -652,8 +652,8 @@ func CellValue(data []byte, pos int, typ byte, metadata uint16, field *querypb.F
return sqltypes.MakeTrusted(querypb.Type_SET,
data[pos:pos+l]), l, nil

case TypeJSON, TypeTinyBlob, TypeMediumBlob, TypeLongBlob, TypeBlob:
// Only TypeBlob is used in binary logs,
case TypeJSON, TypeTinyBlob, TypeMediumBlob, TypeLongBlob, TypeBlob, TypeVector:
// Only TypeBlob and TypeVector is used in binary logs,
// but supports others just in case.
l := 0
switch metadata {
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/binlog_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ type BinlogFormat struct {
HeaderSizes []byte

// ServerVersion is the name of the MySQL server version.
// It starts with something like 5.6.33-xxxx.
// It starts with something like 8.0.34-xxxx.
ServerVersion string

// FormatVersion is the version number of the binlog file format.
Expand Down
7 changes: 4 additions & 3 deletions go/mysql/binlog_event_rbr.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
tableMapEnumAndSetDefaultCharset
tableMapEnumAndSetColumnCharset
tableMapColumnVisibility
tableMapVectorDimensionality
)

// This byte in the optional metadata indicates that we should
Expand Down Expand Up @@ -136,7 +137,7 @@ func metadataLength(typ byte) int {
// No data here.
return 0

case binlog.TypeFloat, binlog.TypeDouble, binlog.TypeTimestamp2, binlog.TypeDateTime2, binlog.TypeTime2, binlog.TypeJSON, binlog.TypeTinyBlob, binlog.TypeMediumBlob, binlog.TypeLongBlob, binlog.TypeBlob, binlog.TypeGeometry:
case binlog.TypeFloat, binlog.TypeDouble, binlog.TypeTimestamp2, binlog.TypeDateTime2, binlog.TypeTime2, binlog.TypeJSON, binlog.TypeTinyBlob, binlog.TypeMediumBlob, binlog.TypeLongBlob, binlog.TypeBlob, binlog.TypeGeometry, binlog.TypeVector:
// One byte.
return 1

Expand Down Expand Up @@ -172,7 +173,7 @@ func metadataRead(data []byte, pos int, typ byte) (uint16, int, error) {
// No data here.
return 0, pos, nil

case binlog.TypeFloat, binlog.TypeDouble, binlog.TypeTimestamp2, binlog.TypeDateTime2, binlog.TypeTime2, binlog.TypeJSON, binlog.TypeTinyBlob, binlog.TypeMediumBlob, binlog.TypeLongBlob, binlog.TypeBlob, binlog.TypeGeometry:
case binlog.TypeFloat, binlog.TypeDouble, binlog.TypeTimestamp2, binlog.TypeDateTime2, binlog.TypeTime2, binlog.TypeJSON, binlog.TypeTinyBlob, binlog.TypeMediumBlob, binlog.TypeLongBlob, binlog.TypeBlob, binlog.TypeGeometry, binlog.TypeVector:
// One byte.
return uint16(data[pos]), pos + 1, nil

Expand All @@ -198,7 +199,7 @@ func metadataWrite(data []byte, pos int, typ byte, value uint16) int {
// No data here.
return pos

case binlog.TypeFloat, binlog.TypeDouble, binlog.TypeTimestamp2, binlog.TypeDateTime2, binlog.TypeTime2, binlog.TypeJSON, binlog.TypeTinyBlob, binlog.TypeMediumBlob, binlog.TypeLongBlob, binlog.TypeBlob, binlog.TypeGeometry:
case binlog.TypeFloat, binlog.TypeDouble, binlog.TypeTimestamp2, binlog.TypeDateTime2, binlog.TypeTime2, binlog.TypeJSON, binlog.TypeTinyBlob, binlog.TypeMediumBlob, binlog.TypeLongBlob, binlog.TypeBlob, binlog.TypeGeometry, binlog.TypeVector:
// One byte.
data[pos] = byte(value)
return pos + 1
Expand Down
3 changes: 0 additions & 3 deletions go/mysql/capabilities/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const (
InstantAddDropColumnFlavorCapability // Adding/dropping column in any position/ordinal.
InstantChangeColumnDefaultFlavorCapability //
InstantExpandEnumCapability //
MySQLJSONFlavorCapability // JSON type supported
MySQLUpgradeInServerFlavorCapability //
DynamicRedoLogCapacityFlavorCapability // supported in MySQL 8.0.30 and above: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-30.html
DisableRedoLogFlavorCapability // supported in MySQL 8.0.21 and above: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-21.html
Expand Down Expand Up @@ -89,8 +88,6 @@ func MySQLVersionHasCapability(serverVersion string, capability FlavorCapability
}
// Capabilities sorted by version.
switch capability {
case MySQLJSONFlavorCapability:
return atLeast(5, 7, 0)
case InstantDDLFlavorCapability,
InstantExpandEnumCapability,
InstantAddLastColumnFlavorCapability,
Expand Down
12 changes: 1 addition & 11 deletions go/mysql/capabilities/capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestMySQLVersionCapableOf(t *testing.T) {
isCapable: false,
},
{
version: "5.6.7",
version: "5.7.29",
capability: InstantDDLFlavorCapability,
isCapable: false,
},
Expand All @@ -154,16 +154,6 @@ func TestMySQLVersionCapableOf(t *testing.T) {
capability: TransactionalGtidExecutedFlavorCapability,
isCapable: false,
},
{
version: "5.6.7",
capability: MySQLJSONFlavorCapability,
isCapable: false,
},
{
version: "5.7.29",
capability: MySQLJSONFlavorCapability,
isCapable: true,
},
{
version: "8.0.30",
capability: DynamicRedoLogCapacityFlavorCapability,
Expand Down
12 changes: 1 addition & 11 deletions go/mysql/flavor_mysqlgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestMysqlGRSupportCapability(t *testing.T) {
isCapable: false,
},
{
version: "5.6.7",
version: "5.7.29",
capability: capabilities.InstantDDLFlavorCapability,
isCapable: false,
},
Expand All @@ -93,16 +93,6 @@ func TestMysqlGRSupportCapability(t *testing.T) {
capability: capabilities.TransactionalGtidExecutedFlavorCapability,
isCapable: false,
},
{
version: "5.6.7",
capability: capabilities.MySQLJSONFlavorCapability,
isCapable: false,
},
{
version: "5.7.29",
capability: capabilities.MySQLJSONFlavorCapability,
isCapable: true,
},
{
version: "8.0.30",
capability: capabilities.DynamicRedoLogCapacityFlavorCapability,
Expand Down
5 changes: 0 additions & 5 deletions go/mysql/flavor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ func TestServerVersionCapableOf(t *testing.T) {
capability: capabilities.TransactionalGtidExecutedFlavorCapability,
isCapable: false,
},
{
version: "5.7.29",
capability: capabilities.MySQLJSONFlavorCapability,
isCapable: true,
},
{
version: "8.0.30",
capability: capabilities.DynamicRedoLogCapacityFlavorCapability,
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ func (c *Conn) parseStmtArgs(data []byte, typ querypb.Type, pos int) (sqltypes.V
return sqltypes.NULL, 0, false
}
case sqltypes.Decimal, sqltypes.Text, sqltypes.Blob, sqltypes.VarChar, sqltypes.VarBinary, sqltypes.Year, sqltypes.Char,
sqltypes.Bit, sqltypes.Enum, sqltypes.Set, sqltypes.Geometry, sqltypes.Binary, sqltypes.TypeJSON:
sqltypes.Bit, sqltypes.Enum, sqltypes.Set, sqltypes.Geometry, sqltypes.Binary, sqltypes.TypeJSON, sqltypes.Vector:
val, pos, ok := readLenEncStringAsBytesCopy(data, pos)
return sqltypes.MakeTrusted(sqltypes.VarBinary, val), pos, ok
default:
Expand Down
3 changes: 3 additions & 0 deletions go/mysql/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ func TestQueries(t *testing.T) {
// Skip TUPLE, not possible in Result.
{Name: "Type_GEOMETRY ", Type: querypb.Type_GEOMETRY, Charset: collations.CollationBinaryID, Flags: uint32(querypb.MySqlFlag_BINARY_FLAG | querypb.MySqlFlag_BLOB_FLAG)},
{Name: "Type_JSON ", Type: querypb.Type_JSON, Charset: collations.CollationUtf8mb4ID},
{Name: "Type_VECTOR ", Type: querypb.Type_VECTOR, Charset: collations.CollationBinaryID},
},
Rows: [][]sqltypes.Value{
{
Expand Down Expand Up @@ -492,6 +493,7 @@ func TestQueries(t *testing.T) {
sqltypes.MakeTrusted(querypb.Type_SET, []byte("Type_SET")),
sqltypes.MakeTrusted(querypb.Type_GEOMETRY, []byte("Type_GEOMETRY")),
sqltypes.MakeTrusted(querypb.Type_JSON, []byte("Type_JSON")),
sqltypes.MakeTrusted(querypb.Type_VECTOR, []byte("Type_VECTOR")),
},
{
sqltypes.NULL,
Expand Down Expand Up @@ -523,6 +525,7 @@ func TestQueries(t *testing.T) {
sqltypes.NULL,
sqltypes.NULL,
sqltypes.NULL,
sqltypes.NULL,
},
},
})
Expand Down
2 changes: 2 additions & 0 deletions go/mysql/sqlerror/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ const (
ERDupIndex = ErrorCode(1831)
ERInnodbReadOnly = ErrorCode(1874)

ERVectorConversion = ErrorCode(6138)

// already exists
ERDbCreateExists = ErrorCode(1007)
ERTableExists = ErrorCode(1050)
Expand Down
1 change: 1 addition & 0 deletions go/mysql/sqlerror/sql_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ var stateToMysqlCode = map[vterrors.State]mysqlCode{
vterrors.KillDeniedError: {num: ERKillDenied, state: SSUnknownSQLState},
vterrors.BadNullError: {num: ERBadNullError, state: SSConstraintViolation},
vterrors.InvalidGroupFuncUse: {num: ERInvalidGroupFuncUse, state: SSUnknownSQLState},
vterrors.VectorConversion: {num: ERVectorConversion, state: SSUnknownSQLState},
}

func getStateToMySQLState(state vterrors.State) mysqlCode {
Expand Down
3 changes: 3 additions & 0 deletions go/sqltypes/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ const (
HexVal = querypb.Type_HEXVAL
Tuple = querypb.Type_TUPLE
BitNum = querypb.Type_BITNUM
Vector = querypb.Type_VECTOR
)

// bit-shift the mysql flags by two byte so we
Expand Down Expand Up @@ -219,6 +220,7 @@ var mysqlToType = map[byte]querypb.Type{
17: Timestamp,
18: Datetime,
19: Time,
242: Vector,
245: TypeJSON,
246: Decimal,
247: Enum,
Expand Down Expand Up @@ -331,6 +333,7 @@ var typeToMySQL = map[querypb.Type]struct {
Datetime: {typ: 12, flags: mysqlBinary},
Year: {typ: 13, flags: mysqlUnsigned},
Bit: {typ: 16, flags: mysqlUnsigned},
Vector: {typ: 242},
TypeJSON: {typ: 245},
Decimal: {typ: 246},
Text: {typ: 252},
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/backup/vtctlbackup/backup_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ func verifySemiSyncStatus(t *testing.T, vttablet *cluster.Vttablet, expectedStat
}

func terminateBackup(t *testing.T, alias string) {
stopBackupMsg := "Done taking Backup"
stopBackupMsg := "Completed backing up"
if useXtrabackup {
stopBackupMsg = "Starting backup with"
useXtrabackup = false
Expand Down
Loading

0 comments on commit b6e6823

Please sign in to comment.