diff --git a/go/sqltypes/result.go b/go/sqltypes/result.go index 2f308f6d210..8ce92eef36f 100644 --- a/go/sqltypes/result.go +++ b/go/sqltypes/result.go @@ -185,13 +185,14 @@ func ResultsEqual(r1, r2 []Result) bool { // Every place this function is called, a comment is needed that explains // why it's justified. func MakeRowTrusted(fields []*querypb.Field, row *querypb.Row) []Value { - sqlRow := make([]Value, len(row.Lengths)) + sqlRow := make([]Value, len(fields)) var offset int64 - for i, length := range row.Lengths { + for i, fld := range fields { + length := row.Lengths[i] if length < 0 { continue } - sqlRow[i] = MakeTrusted(fields[i].Type, row.Values[offset:offset+length]) + sqlRow[i] = MakeTrusted(fld.Type, row.Values[offset:offset+length]) offset += length } return sqlRow diff --git a/go/sqltypes/result_test.go b/go/sqltypes/result_test.go index 2ddeaa59b34..3f09f1085c0 100644 --- a/go/sqltypes/result_test.go +++ b/go/sqltypes/result_test.go @@ -23,6 +23,61 @@ import ( querypb "vitess.io/vitess/go/vt/proto/query" ) +func TestMakeRowTrusted(t *testing.T) { + fields := MakeTestFields( + "some_int|some_text|another_int", + "int8|varchar|int8", + ) + + values := []byte{} + hw := []byte("hello, world") + values = append(values, hw...) + values = append(values, byte(42)) + + row := &querypb.Row{ + Lengths: []int64{-1, int64(len(hw)), 1}, + Values: values, + } + + want := []Value{ + MakeTrusted(querypb.Type_NULL_TYPE, nil), + MakeTrusted(querypb.Type_VARCHAR, []byte("hello, world")), + MakeTrusted(querypb.Type_INT8, []byte{byte(42)}), + } + + result := MakeRowTrusted(fields, row) + if !reflect.DeepEqual(result, want) { + t.Errorf("MakeRowTrusted:\ngot: %#v\nwant: %#v", result, want) + } +} + +func TestMakeRowTrustedDoesNotPanicOnNewColumns(t *testing.T) { + fields := MakeTestFields( + "some_int|some_text", + "int8|varchar", + ) + + values := []byte{byte(123)} + hw := []byte("hello, world") + values = append(values, hw...) + values = append(values, byte(42)) + + row := &querypb.Row{ + Lengths: []int64{1, int64(len(hw)), 1}, + Values: values, + } + + want := []Value{ + MakeTrusted(querypb.Type_INT8, []byte{byte(123)}), + MakeTrusted(querypb.Type_VARCHAR, []byte("hello, world")), + } + + result := MakeRowTrusted(fields, row) + if !reflect.DeepEqual(result, want) { + t.Errorf("MakeRowTrusted:\ngot: %#v\nwant: %#v", result, want) + } +} + func TestRepair(t *testing.T) { fields := []*querypb.Field{{ Type: Int64, diff --git a/go/vt/discovery/tablet_stats_cache.go b/go/vt/discovery/tablet_stats_cache.go index 92208266e1c..f77b23ae07e 100644 --- a/go/vt/discovery/tablet_stats_cache.go +++ b/go/vt/discovery/tablet_stats_cache.go @@ -235,14 +235,17 @@ func (tc *TabletStatsCache) StatsUpdate(ts *TabletStats) { // values if necessary. (will update both // 'all' and 'healthy' as they use pointers). if !trivialNonMasterUpdate { + log.Infof("SLACK:tablet stats cache::master update - %+v", ts) *existing = *ts } } else { + log.Infof("SLACK:tablet stats cache::removing tablet entry - %+v", ts) // We have an entry which we shouldn't. Remove it. delete(e.all, ts.Key) } } else { if ts.Up { + log.Infof("SLACK:tablet stats cache::adding tablet - %+v", ts) // Add the entry. e.all[ts.Key] = ts } else { @@ -261,6 +264,7 @@ func (tc *TabletStatsCache) StatsUpdate(ts *TabletStats) { for _, s := range e.all { allArray = append(allArray, s) } + log.Infof("SLACK:tablet stats cache::master healthy list - %v", allArray) } else { // For non-master, if it is a trivial update, // we just skip everything else. We don't even update the @@ -274,6 +278,7 @@ func (tc *TabletStatsCache) StatsUpdate(ts *TabletStats) { for _, s := range e.all { allArray = append(allArray, s) } + log.Infof("SLACK:tablet stats cache::healthy list recomputed - %v", allArray) e.healthy = FilterByReplicationLag(allArray) } diff --git a/test/config.json b/test/config.json index ea0d559f6f6..62a02765f8f 100644 --- a/test/config.json +++ b/test/config.json @@ -247,6 +247,28 @@ "RetryMax": 0, "Tags": [] }, + "cell_no_aliases": { + "File": "cell_no_aliases.py", + "Args": [], + "Command": [], + "Manual": false, + "Shard": 1, + "RetryMax": 0, + "Tags": [ + "site_test" + ] + }, + "cell_aliases": { + "File": "cell_aliases.py", + "Args": [], + "Command": [], + "Manual": false, + "Shard": 1, + "RetryMax": 0, + "Tags": [ + "site_test" + ] + }, "mysql_server": { "File": "mysql_server_test.py", "Args": [],