Skip to content

Commit

Permalink
VIndexes: Stop recommending md5 based vindex types as md5 is consider…
Browse files Browse the repository at this point in the history
…ed insecure (#16113)

Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord authored Jun 24, 2024
1 parent 13e5d33 commit bdcb43d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func registerCommands(root *cobra.Command) {
create.Flags().StringSliceVar(&createOptions.TableOwnerColumns, "table-owner-columns", nil, "The columns to read from the owner table. These will be used to build the hash which gets stored as the keyspace_id value in the lookup table.")
create.MarkFlagRequired("table-owner-columns")
create.Flags().StringVar(&createOptions.TableName, "table-name", "", "The name of the lookup table. If not specified, then it will be created using the same name as the Lookup Vindex.")
create.Flags().StringVar(&createOptions.TableVindexType, "table-vindex-type", "", "The primary vindex name/type to use for the lookup table, if the table-keyspace is sharded. This must match the name of a vindex defined in the table-keyspace. If no value is provided then the default type will be used based on the table-owner-columns types.")
create.Flags().StringVar(&createOptions.TableVindexType, "table-vindex-type", "", "The primary vindex name/type to use for the lookup table, if the table-keyspace is sharded. If no value is provided then the default type will be used based on the table-owner-columns types.")
create.Flags().BoolVar(&createOptions.IgnoreNulls, "ignore-nulls", false, "Do not add corresponding records in the lookup table if any of the owner table's 'from' fields are NULL.")
create.Flags().BoolVar(&createOptions.ContinueAfterCopyWithOwner, "continue-after-copy-with-owner", true, "Vindex will continue materialization after the backfill completes when an owner is provided.")
// VReplication specific flags.
Expand Down
20 changes: 10 additions & 10 deletions go/vt/vtctl/workflow/materializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1531,15 +1531,15 @@ func TestCreateLookupVindexTargetVSchema(t *testing.T) {
out: &vschemapb.Keyspace{
Sharded: true,
Vindexes: map[string]*vschemapb.Vindex{
"unicode_loose_md5": {
Type: "unicode_loose_md5",
"unicode_loose_xxhash": {
Type: "unicode_loose_xxhash",
},
},
Tables: map[string]*vschemapb.Table{
"lkp": {
ColumnVindexes: []*vschemapb.ColumnVindex{{
Column: "c1",
Name: "unicode_loose_md5",
Name: "unicode_loose_xxhash",
}},
},
},
Expand Down Expand Up @@ -1581,7 +1581,7 @@ func TestCreateLookupVindexTargetVSchema(t *testing.T) {
Vindexes: map[string]*vschemapb.Vindex{
// Create a misleading vindex name.
"xxhash": {
Type: "unicode_loose_md5",
Type: "unicode_loose_xxhash",
},
},
},
Expand Down Expand Up @@ -1803,7 +1803,7 @@ func TestCreateCustomizedVindex(t *testing.T) {
},
"lookup": {
ColumnVindexes: []*vschemapb.ColumnVindex{{
Name: "unicode_loose_md5",
Name: "unicode_loose_xxhash",
Column: "c1",
}},
},
Expand All @@ -1823,8 +1823,8 @@ func TestCreateCustomizedVindex(t *testing.T) {
"xxhash": {
Type: "xxhash",
},
"unicode_loose_md5": { // Non default vindex type for the column.
Type: "unicode_loose_md5",
"unicode_loose_xxhash": { // Non default vindex type for the column.
Type: "unicode_loose_xxhash",
},
},
Tables: map[string]*vschemapb.Table{
Expand All @@ -1842,8 +1842,8 @@ func TestCreateCustomizedVindex(t *testing.T) {
"xxhash": {
Type: "xxhash",
},
"unicode_loose_md5": {
Type: "unicode_loose_md5",
"unicode_loose_xxhash": {
Type: "unicode_loose_xxhash",
},
"v": {
Type: "lookup_unique",
Expand All @@ -1869,7 +1869,7 @@ func TestCreateCustomizedVindex(t *testing.T) {
"lookup": {
ColumnVindexes: []*vschemapb.ColumnVindex{{
Column: "c1",
Name: "unicode_loose_md5",
Name: "unicode_loose_xxhash",
}},
},
},
Expand Down
6 changes: 2 additions & 4 deletions go/vt/vtgate/vindexes/vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1378,12 +1378,10 @@ func LoadFormalKeyspace(filename string) (*vschemapb.Keyspace, error) {
// the given SQL data type.
func ChooseVindexForType(typ querypb.Type) (string, error) {
switch {
case sqltypes.IsIntegral(typ):
case sqltypes.IsIntegral(typ) || sqltypes.IsBinary(typ):
return "xxhash", nil
case sqltypes.IsText(typ):
return "unicode_loose_md5", nil
case sqltypes.IsBinary(typ):
return "binary_md5", nil
return "unicode_loose_xxhash", nil
}
return "", vterrors.Errorf(
vtrpcpb.Code_INVALID_ARGUMENT,
Expand Down
12 changes: 6 additions & 6 deletions go/vt/vtgate/vindexes/vschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,22 +960,22 @@ func TestChooseVindexForType(t *testing.T) {
out: "",
}, {
in: sqltypes.Text,
out: "unicode_loose_md5",
out: "unicode_loose_xxhash",
}, {
in: sqltypes.Blob,
out: "binary_md5",
out: "xxhash",
}, {
in: sqltypes.VarChar,
out: "unicode_loose_md5",
out: "unicode_loose_xxhash",
}, {
in: sqltypes.VarBinary,
out: "binary_md5",
out: "xxhash",
}, {
in: sqltypes.Char,
out: "unicode_loose_md5",
out: "unicode_loose_xxhash",
}, {
in: sqltypes.Binary,
out: "binary_md5",
out: "xxhash",
}, {
in: sqltypes.Bit,
out: "",
Expand Down
8 changes: 4 additions & 4 deletions go/vt/wrangler/materializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,15 +952,15 @@ func TestCreateLookupVindexTargetVSchema(t *testing.T) {
out: &vschemapb.Keyspace{
Sharded: true,
Vindexes: map[string]*vschemapb.Vindex{
"unicode_loose_md5": {
Type: "unicode_loose_md5",
"unicode_loose_xxhash": {
Type: "unicode_loose_xxhash",
},
},
Tables: map[string]*vschemapb.Table{
"lkp": {
ColumnVindexes: []*vschemapb.ColumnVindex{{
Column: "c1",
Name: "unicode_loose_md5",
Name: "unicode_loose_xxhash",
}},
},
},
Expand Down Expand Up @@ -1002,7 +1002,7 @@ func TestCreateLookupVindexTargetVSchema(t *testing.T) {
Vindexes: map[string]*vschemapb.Vindex{
// Create a misleading vindex name.
"xxhash": {
Type: "unicode_loose_md5",
Type: "unicode_loose_xxhash",
},
},
},
Expand Down

0 comments on commit bdcb43d

Please sign in to comment.