Skip to content

Commit

Permalink
Merge branch 'vitessio:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
marsian83 authored Oct 9, 2023
2 parents 7860a6e + 80c9834 commit 2a3e5fa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ansible/macrobench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
gateway_targets: "{% set targets = [] -%}{% for host in groups['vtgate'] -%}{% for gateway in hostvars[host]['gateways'] -%}{{ targets.append( hostvars[host]['ansible_default_ipv4']['address']+':'+ (gateway.port | default(15001) | string )) }}{% endfor -%}{% endfor -%}{{ targets }}"
vtctld_targets: "{% set targets = [] -%}{% for host in groups['vtctld'] -%}{{ targets.append( hostvars[host]['ansible_default_ipv4']['address']+':'+ (vtctld_port | default(15000) | string )) }}{% endfor -%}{{ targets }}"
node_targets: "{% set targets= [] -%}{% for host in groups['all'] -%}{{ targets.append( hostvars[host]['ansible_default_ipv4']['address']+':9100' ) }}{% endfor -%}{{ targets }}"
prometheus_skip_install: true
prometheus_skip_install: false
prometheus_targets:
tablets:
- targets: '{{ tablet_targets }}'
Expand Down
32 changes: 30 additions & 2 deletions go/tools/macrobench/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
package macrobench

import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"sort"
"strings"
Expand All @@ -42,6 +44,8 @@ type VTGateQueryPlanValue struct {
RowsReturned int // Total number of rows
RowsAffected int // Total number of rows
Errors int // Total number of errors

TablesUsed interface{}
}

type VTGateQueryPlan struct {
Expand Down Expand Up @@ -158,8 +162,32 @@ func getVTGateQueryPlans(port string) (VTGateQueryPlanMap, error) {
}
defer resp.Body.Close()

respBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

var response map[string]VTGateQueryPlanValue
err = json.NewDecoder(bytes.NewReader(respBytes)).Decode(&response)
if err != nil {
return getOldVTGateQueryPlans(respBytes)
}
for key, plan := range response {
// keeping only select statements
if strings.HasPrefix(key, "select") {
jsonPlan, err := json.MarshalIndent(plan.Instructions, "", "\t")
if err != nil {
return nil, err
}
plan.Instructions = string(jsonPlan)
}
}
return response, nil
}

func getOldVTGateQueryPlans(respBytes []byte) (VTGateQueryPlanMap, error) {
var response []VTGateQueryPlan
err = json.NewDecoder(resp.Body).Decode(&response)
err := json.NewDecoder(bytes.NewReader(respBytes)).Decode(&response)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -230,7 +258,7 @@ func GetVTGateSelectQueryPlansWithFilter(gitRef string, macroType Type, planner
case []byte:
plan.Value.Instructions = string(p)
}

// Remove all comments from the query
// This prevents the query from not match across two versions
// of Vitess where we changed query hints and added comments
Expand Down

0 comments on commit 2a3e5fa

Please sign in to comment.