diff --git a/go/cache/lru_cache.go b/go/cache/lru_cache.go index 819240ca6f4..a94482e74a3 100644 --- a/go/cache/lru_cache.go +++ b/go/cache/lru_cache.go @@ -222,7 +222,7 @@ func (lru *LRUCache) Oldest() (oldest time.Time) { } // Keys returns all the keys for the cache, ordered from most recently -// used to last recently used. +// used to least recently used. func (lru *LRUCache) Keys() []string { lru.mu.Lock() defer lru.mu.Unlock() @@ -235,7 +235,7 @@ func (lru *LRUCache) Keys() []string { } // Items returns all the values for the cache, ordered from most recently -// used to last recently used. +// used to least recently used. func (lru *LRUCache) Items() []Item { lru.mu.Lock() defer lru.mu.Unlock() diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index dba611676b2..1c6f8e04133 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -1345,20 +1345,15 @@ func (e *Executor) ServeHTTP(response http.ResponseWriter, request *http.Request return } if request.URL.Path == "/debug/query_plans" { - keys := e.plans.Keys() - response.Header().Set("Content-Type", "text/plain") - response.Write([]byte(fmt.Sprintf("Length: %d\n", len(keys)))) - for _, v := range keys { - response.Write([]byte(fmt.Sprintf("%#v\n", sqlparser.TruncateForUI(v)))) - if plan, ok := e.plans.Peek(v); ok { - if b, err := json.MarshalIndent(plan, "", " "); err != nil { - response.Write([]byte(err.Error())) - } else { - response.Write(b) - } - response.Write(([]byte)("\n\n")) - } + response.Header().Set("Content-Type", "application/json; charset=utf-8") + buf, err := json.MarshalIndent(e.plans.Items(), "", " ") + if err != nil { + response.Write([]byte(err.Error())) + return } + ebuf := bytes.NewBuffer(nil) + json.HTMLEscape(ebuf, buf) + response.Write(ebuf.Bytes()) } else if request.URL.Path == "/debug/vschema" { response.Header().Set("Content-Type", "application/json; charset=utf-8") b, err := json.MarshalIndent(e.VSchema(), "", " ") @@ -1384,7 +1379,6 @@ func (e *Executor) updateQueryCounts(planType, keyspace, tableName string, shard queriesRouted.Add(planType, shardQueries) queriesProcessedByTable.Add([]string{planType, keyspace, tableName}, 1) queriesRoutedByTable.Add([]string{planType, keyspace, tableName}, shardQueries) - return } // VSchemaStats returns the loaded vschema stats.