Skip to content

Commit

Permalink
vtgate: fix race condition iterating tables and views from schema tra…
Browse files Browse the repository at this point in the history
…cker (vitessio#13673)
  • Loading branch information
brendar authored Aug 16, 2023
1 parent d48782e commit 24ea6f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions go/vt/vtgate/schema/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down

0 comments on commit 24ea6f2

Please sign in to comment.