diff --git a/go/vt/vtgate/schema/tracker.go b/go/vt/vtgate/schema/tracker.go index 0df020869bf..74737b3cd82 100644 --- a/go/vt/vtgate/schema/tracker.go +++ b/go/vt/vtgate/schema/tracker.go @@ -22,6 +22,8 @@ import ( "sync" "time" + "golang.org/x/exp/maps" + "vitess.io/vitess/go/vt/discovery" "vitess.io/vitess/go/vt/log" querypb "vitess.io/vitess/go/vt/proto/query" @@ -221,7 +223,7 @@ func (t *Tracker) Tables(ks string) map[string]*vindexes.TableInfo { return map[string]*vindexes.TableInfo{} // we know nothing about this KS, so that is the info we can give out } - return m + return maps.Clone(m) } // Views returns all known views in the keyspace with their definition. @@ -232,7 +234,9 @@ func (t *Tracker) Views(ks string) map[string]sqlparser.SelectStatement { if t.views == nil { return nil } - return t.views.m[ks] + + m := t.views.m[ks] + return maps.Clone(m) } func (t *Tracker) updateSchema(th *discovery.TabletHealth) bool {