Repository: vitessio/vitess
Pull request #7902 (2021-04-20 14:52:29)

Planbuilder: Add fuzzer
This PR adds a fuzzer for vtgate/planbuilder.

An update in the OSS-fuzz build script is required, but I will add that in a separate PR since https://github.com/vitessio/vitess/pull/7782 is currently a blocker for that.


Patch:
diff --git a/.github/workflows/check_formatting.yml b/.github/workflows/check_formatting.yml
index a34b356d87..3f2334dd4b 100644
--- a/.github/workflows/check_formatting.yml
+++ b/.github/workflows/check_formatting.yml
@@ -12,16 +12,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/check_make_parser.yml b/.github/workflows/check_make_parser.yml
index 0f3ec9cff2..805cf2fe49 100644
--- a/.github/workflows/check_make_parser.yml
+++ b/.github/workflows/check_make_parser.yml
@@ -12,16 +12,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/check_make_sizegen.yml b/.github/workflows/check_make_sizegen.yml
index 7250324ab5..b8eef13acf 100644
--- a/.github/workflows/check_make_sizegen.yml
+++ b/.github/workflows/check_make_sizegen.yml
@@ -6,40 +6,30 @@ jobs:
     name: Check Make Sizegen
     runs-on: ubuntu-latest
     steps:
-    
-    - name: Set up Go
-      uses: actions/setup-go@v1
-      with:
-        go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
-    - name: Check out code
-      uses: actions/checkout@v2
-
-    - name: Get dependencies
-      run: |
-        sudo apt-get update
-        sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget
-        sudo service mysql stop
-        sudo service etcd stop
-        sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
-        sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
-        go mod download
-
-    - name: Run make minimaltools
-      run: |
-        make minimaltools
-
-    - name: check_make_sizegen
-      run: |
-        tools/check_make_sizegen.sh
+      - name: Set up Go
+        uses: actions/setup-go@v1
+        with:
+          go-version: 1.15
+
+      - name: Check out code
+        uses: actions/checkout@v2
+
+      - name: Get dependencies
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget
+          sudo service mysql stop
+          sudo service etcd stop
+          sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
+          sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
+          go mod download
+
+      - name: Run make minimaltools
+        run: |
+          make minimaltools
+
+      - name: check_make_sizegen
+        run: |
+          tools/check_make_sizegen.sh
 
diff --git a/.github/workflows/check_make_visitor.yml b/.github/workflows/check_make_visitor.yml
index 6c966b10d3..a23a8680a2 100644
--- a/.github/workflows/check_make_visitor.yml
+++ b/.github/workflows/check_make_visitor.yml
@@ -12,16 +12,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/cluster_endtoend_upgrade.yml b/.github/workflows/cluster_endtoend_upgrade.yml
index 85528a3442..336b175ac0 100644
--- a/.github/workflows/cluster_endtoend_upgrade.yml
+++ b/.github/workflows/cluster_endtoend_upgrade.yml
@@ -13,16 +13,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out v9.0.0
       uses: actions/checkout@v2
       with:
diff --git a/.github/workflows/cluster_initial_sharding_multi.yml b/.github/workflows/cluster_initial_sharding_multi.yml
index 9d15898ce3..147b8e7e1c 100644
--- a/.github/workflows/cluster_initial_sharding_multi.yml
+++ b/.github/workflows/cluster_initial_sharding_multi.yml
@@ -12,16 +12,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml
index 9c7d477b07..85a4d098d5 100644
--- a/.github/workflows/create_release.yml
+++ b/.github/workflows/create_release.yml
@@ -18,16 +18,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/endtoend.yml b/.github/workflows/endtoend.yml
index ee6b0a0f30..c020d356ab 100644
--- a/.github/workflows/endtoend.yml
+++ b/.github/workflows/endtoend.yml
@@ -12,16 +12,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/ensure_bootstrap_updated.yml b/.github/workflows/ensure_bootstrap_updated.yml
index 2b5a0c5bd5..3ec8261c9b 100644
--- a/.github/workflows/ensure_bootstrap_updated.yml
+++ b/.github/workflows/ensure_bootstrap_updated.yml
@@ -12,16 +12,6 @@ jobs:
       with:
         go-version: 1.13
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml
deleted file mode 100644
index 59f1592985..0000000000
--- a/.github/workflows/fossa.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-name: FOSSA License Scanning
-
-on:
-  - pull_request
-  - push
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-
-    steps:
-      - name: Checkout code
-        uses: actions/checkout@v2
-
-      - name: Run FOSSA scan and upload build data
-        uses: fossa-contrib/fossa-action@v1
-        with:
-          fossa-api-key: 76d7483ea206d530d9452e44bffe7ba8
-
diff --git a/.github/workflows/golangci-linter.yml b/.github/workflows/golangci-linter.yml
index 5056d5973e..98bdd56ea7 100644
--- a/.github/workflows/golangci-linter.yml
+++ b/.github/workflows/golangci-linter.yml
@@ -5,33 +5,23 @@ jobs:
     name: Lint using golangci-lint
     runs-on: ubuntu-latest
     steps:
-    - name: Set up Go 1.15
-      uses: actions/setup-go@v1
-      with:
-        go-version: 1.15
-      id: go
+      - name: Set up Go 1.15
+        uses: actions/setup-go@v1
+        with:
+          go-version: 1.15
+        id: go
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
+      - name: Check out code into the Go module directory
+        uses: actions/checkout@v2
 
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
+      - name: Install golangci-lint
+        run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.31.0
 
-    - name: Check out code into the Go module directory
-      uses: actions/checkout@v2
+      - name: Clean Env
+        run: $(go env GOPATH)/bin/golangci-lint cache clean
 
-    - name: Install golangci-lint
-      run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.31.0
+      - name: Print linter version
+        run: $(go env GOPATH)/bin/golangci-lint --version
 
-    - name: Clean Env
-      run: $(go env GOPATH)/bin/golangci-lint cache clean
-
-    - name: Print linter version
-      run: $(go env GOPATH)/bin/golangci-lint --version
-
-    - name: Run golangci-lint
-      run: $(go env GOPATH)/bin/golangci-lint run go/...
+      - name: Run golangci-lint
+        run: $(go env GOPATH)/bin/golangci-lint run go/...
diff --git a/.github/workflows/gomod-tidy.yml b/.github/workflows/gomod-tidy.yml
index 67f1f4edc6..34dbdd2d5c 100644
--- a/.github/workflows/gomod-tidy.yml
+++ b/.github/workflows/gomod-tidy.yml
@@ -5,34 +5,24 @@ jobs:
     name: Check go mod tidy
     runs-on: ubuntu-latest
     steps:
-    - name: Set up Go 1.15
-      uses: actions/setup-go@v1
-      with:
-        go-version: 1.15
-      id: go
+      - name: Set up Go 1.15
+        uses: actions/setup-go@v1
+        with:
+          go-version: 1.15
+        id: go
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
+      - name: Check out code into the Go module directory
+        uses: actions/checkout@v2
 
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
-    - name: Check out code into the Go module directory
-      uses: actions/checkout@v2
-
-    - name: Run go mod tidy
-      run: |
-        set -e
-        go mod tidy
-        output=$(git status -s)
-        if [ -z "${output}" ]; then
-          exit 0
-        fi
-        echo 'We wish to maintain a tidy state for go mod. Please run `go mod tidy` on your branch, commit and push again.'
-        echo 'Running `go mod tidy` on this CI test yields with the following changes:'
-        echo "$output"
-        exit 1
+      - name: Run go mod tidy
+        run: |
+          set -e
+          go mod tidy
+          output=$(git status -s)
+          if [ -z "${output}" ]; then
+           exit 0
+          fi
+          echo 'We wish to maintain a tidy state for go mod. Please run `go mod tidy` on your branch, commit and push again.'
+          echo 'Running `go mod tidy` on this CI test yields with the following changes:'
+          echo "$output"
+          exit 1
diff --git a/.github/workflows/legacy_local_example.yml b/.github/workflows/legacy_local_example.yml
index b09e8a2151..568ac5a2c0 100644
--- a/.github/workflows/legacy_local_example.yml
+++ b/.github/workflows/legacy_local_example.yml
@@ -17,16 +17,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/local_example.yml b/.github/workflows/local_example.yml
index 324d6d41a8..aa996f7eca 100644
--- a/.github/workflows/local_example.yml
+++ b/.github/workflows/local_example.yml
@@ -17,16 +17,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/region_example.yml b/.github/workflows/region_example.yml
index eedcdc40ee..e19b78e16a 100644
--- a/.github/workflows/region_example.yml
+++ b/.github/workflows/region_example.yml
@@ -17,16 +17,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/sonar_analysis.yml b/.github/workflows/sonar_analysis.yml
index ff470b8a1c..3381d93b22 100644
--- a/.github/workflows/sonar_analysis.yml
+++ b/.github/workflows/sonar_analysis.yml
@@ -14,16 +14,6 @@ jobs:
         with:
           go-version: 1.13
 
-      - name: Tune the OS
-        run: |
-          echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-      # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-      - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-        run: |
-          echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-      # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
       - name: Check out code
         uses: actions/checkout@v2
 
diff --git a/.github/workflows/unit_race.yml b/.github/workflows/unit_race.yml
index b85dba5d2f..134d20512a 100644
--- a/.github/workflows/unit_race.yml
+++ b/.github/workflows/unit_race.yml
@@ -12,16 +12,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index 683e3911a6..125cd85560 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -5,7 +5,7 @@ The following is the full list, alphabetically ordered.
 * Alkin Tezuysal ([askdba](https://github.com/askdba)) alkin@planetscale.com
 * Andres Taylor ([systay](https://github.com/systay)) andres@planetscale.com
 * Andrew Mason ([amason](https://github.com/ajm188)) amason@slack-corp.com
-* Anthony Yeh ([enisoc](https://github.com/enisoc)) enisoc@enisoc.dev
+* Anthony Yeh ([enisoc](https://github.com/enisoc)) enisoc@planetscale.com
 * Dan Kozlowski ([dkhenry](https://github.com/dkhenry)) dan.kozlowski@gmail.com
 * David Weitzman ([dweitzman](https://github.com/dweitzman)) dweitzman@pinterest.com
 * Deepthi Sigireddi ([deepthi](https://github.com/deepthi)) deepthi@planetscale.com
diff --git a/go/mysql/mysql_fuzzer.go b/go/mysql/mysql_fuzzer.go
index 4cfcd3619d..569475c8b8 100644
--- a/go/mysql/mysql_fuzzer.go
+++ b/go/mysql/mysql_fuzzer.go
@@ -31,6 +31,7 @@ import (
 
 	"vitess.io/vitess/go/sqltypes"
 	querypb "vitess.io/vitess/go/vt/proto/query"
+	"vitess.io/vitess/go/vt/sqlparser"
 	"vitess.io/vitess/go/vt/tlstest"
 	"vitess.io/vitess/go/vt/vttls"
 )
@@ -301,29 +302,23 @@ func (th *fuzzTestHandler) WarningCount(c *Conn) uint16 {
 	return th.warnings
 }
 
-func (c *Conn) writeFuzzedPacket(packet []byte) {
-	c.sequence = 0
-	data, pos := c.startEphemeralPacketWithHeader(len(packet) + 1)
-	copy(data[pos:], packet)
-	_ = c.writeEphemeralPacket()
-}
-
 func FuzzTLSServer(data []byte) int {
-	if len(data) < 40 {
-		return -1
-	}
 	// totalQueries is the number of queries the fuzzer
 	// makes in each fuzz iteration
 	totalQueries := 20
-	var queries [][]byte
+	var queries []string
 	c := gofuzzheaders.NewConsumer(data)
 	for i := 0; i < totalQueries; i++ {
-		query, err := c.GetBytes()
+		query, err := c.GetString()
 		if err != nil {
 			return -1
 		}
-		if len(query) < 40 {
-			continue
+
+		// We parse each query now to exit if the queries
+		// are invalid
+		_, err = sqlparser.Parse(query)
+		if err != nil {
+			return -1
 		}
 		queries = append(queries, query)
 	}
@@ -384,7 +379,7 @@ func FuzzTLSServer(data []byte) int {
 	}
 
 	for i := 0; i < len(queries); i++ {
-		conn.writeFuzzedPacket(queries[i])
+		_, _ = conn.ExecuteFetch(queries[i], 1000, true)
 	}
 	return 1
 }
diff --git a/go/vt/vtadmin/cluster/discovery/discovery.go b/go/vt/vtadmin/cluster/discovery/discovery.go
index d0763ff037..616c29a9f3 100644
--- a/go/vt/vtadmin/cluster/discovery/discovery.go
+++ b/go/vt/vtadmin/cluster/discovery/discovery.go
@@ -20,7 +20,6 @@ import (
 	"context"
 	"errors"
 	"fmt"
-	"sync"
 
 	"github.com/spf13/pflag"
 
@@ -83,15 +82,11 @@ type Factory func(cluster *vtadminpb.Cluster, flags *pflag.FlagSet, args []strin
 
 // nolint:gochecknoglobals
 var registry = map[string]Factory{}
-var registryMu sync.Mutex
 
 // Register registers a factory for the given implementation name. Attempting
 // to register multiple factories for the same implementation name causes a
 // panic.
 func Register(name string, factory Factory) {
-	registryMu.Lock()
-	defer registryMu.Unlock()
-
 	_, ok := registry[name]
 	if ok {
 		panic("[discovery] factory already registered for " + name)
@@ -104,10 +99,7 @@ func Register(name string, factory Factory) {
 // implementation. Usage of the args slice is dependent on the implementation's
 // factory.
 func New(impl string, cluster *vtadminpb.Cluster, args []string) (Discovery, error) {
-	registryMu.Lock()
 	factory, ok := registry[impl]
-	registryMu.Unlock()
-
 	if !ok {
 		return nil, fmt.Errorf("%w %s", ErrImplementationNotRegistered, impl)
 	}
diff --git a/go/vt/vtexplain/vtexplain.go b/go/vt/vtexplain/vtexplain.go
index cf97a32452..6c4476ebbf 100644
--- a/go/vt/vtexplain/vtexplain.go
+++ b/go/vt/vtexplain/vtexplain.go
@@ -155,7 +155,7 @@ func Init(vSchemaStr, sqlSchema, ksShardMapStr string, opts *Options) error {
 		return fmt.Errorf("parseSchema: %v", err)
 	}
 
-	globalTabletEnv, err = newTabletEnvironment(parsedDDLs, opts)
+	err = initTabletEnvironment(parsedDDLs, opts)
 	if err != nil {
 		return fmt.Errorf("initTabletEnvironment: %v", err)
 	}
diff --git a/go/vt/vtexplain/vtexplain_vttablet.go b/go/vt/vtexplain/vtexplain_vttablet.go
index 7f1c76f2c0..c955d4e6b7 100644
--- a/go/vt/vtexplain/vtexplain_vttablet.go
+++ b/go/vt/vtexplain/vtexplain_vttablet.go
@@ -44,18 +44,15 @@ import (
 	topodatapb "vitess.io/vitess/go/vt/proto/topodata"
 )
 
-type tabletEnv struct {
+var (
 	// map of schema introspection queries to their expected results
 	schemaQueries map[string]*sqltypes.Result
 
 	// map for each table from the column name to its type
 	tableColumns map[string]map[string]querypb.Type
-}
 
-var (
 	// time simulator
-	batchTime       *sync2.Batcher
-	globalTabletEnv *tabletEnv
+	batchTime *sync2.Batcher
 )
 
 // explainTablet is the query service that simulates a tablet.
@@ -273,11 +270,9 @@ func (t *explainTablet) Close(ctx context.Context) error {
 	return t.tsv.Close(ctx)
 }
 
-func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) (*tabletEnv, error) {
-	var tEnv tabletEnv
-
-	tEnv.tableColumns = make(map[string]map[string]querypb.Type)
-	tEnv.schemaQueries = map[string]*sqltypes.Result{
+func initTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) error {
+	tableColumns = make(map[string]map[string]querypb.Type)
+	schemaQueries = map[string]*sqltypes.Result{
 		"select unix_timestamp()": {
 			Fields: []*querypb.Field{{
 				Type: sqltypes.Uint64,
@@ -394,7 +389,7 @@ func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) (*tablet
 		}
 		showTableRows = append(showTableRows, mysql.BaseShowTablesRow(table, false, options))
 	}
-	tEnv.schemaQueries[mysql.TablesWithSize57] = &sqltypes.Result{
+	schemaQueries[mysql.TablesWithSize57] = &sqltypes.Result{
 		Fields: mysql.BaseShowTablesFields,
 		Rows:   showTableRows,
 	}
@@ -405,10 +400,10 @@ func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) (*tablet
 
 		if ddl.GetOptLike() != nil {
 			likeTable := ddl.GetOptLike().LikeTable.Name.String()
-			if _, ok := tEnv.schemaQueries["select * from "+likeTable+" where 1 != 1"]; !ok {
-				return nil, fmt.Errorf("check your schema, table[%s] doesn't exist", likeTable)
+			if _, ok := schemaQueries["select * from "+likeTable+" where 1 != 1"]; !ok {
+				return fmt.Errorf("check your schema, table[%s] doesn't exist", likeTable)
 			}
-			tEnv.schemaQueries["select * from "+table+" where 1 != 1"] = tEnv.schemaQueries["select * from "+likeTable+" where 1 != 1"]
+			schemaQueries["select * from "+table+" where 1 != 1"] = schemaQueries["select * from "+likeTable+" where 1 != 1"]
 			continue
 		}
 		for _, idx := range ddl.GetTableSpec().Indexes {
@@ -421,7 +416,7 @@ func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) (*tablet
 			}
 		}
 
-		tEnv.tableColumns[table] = make(map[string]querypb.Type)
+		tableColumns[table] = make(map[string]querypb.Type)
 		var rowTypes []*querypb.Field
 		for _, col := range ddl.GetTableSpec().Columns {
 			colName := strings.ToLower(col.Name.String())
@@ -430,19 +425,19 @@ func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) (*tablet
 				Type: col.Type.SQLType(),
 			}
 			rowTypes = append(rowTypes, rowType)
-			tEnv.tableColumns[table][colName] = col.Type.SQLType()
+			tableColumns[table][colName] = col.Type.SQLType()
 		}
-		tEnv.schemaQueries["select * from "+table+" where 1 != 1"] = &sqltypes.Result{
+		schemaQueries["select * from "+table+" where 1 != 1"] = &sqltypes.Result{
 			Fields: rowTypes,
 		}
 	}
 
-	tEnv.schemaQueries[mysql.BaseShowPrimary] = &sqltypes.Result{
+	schemaQueries[mysql.BaseShowPrimary] = &sqltypes.Result{
 		Fields: mysql.ShowPrimaryFields,
 		Rows:   indexRows,
 	}
 
-	return &tEnv, nil
+	return nil
 }
 
 // HandleQuery implements the fakesqldb query handler interface
@@ -458,7 +453,7 @@ func (t *explainTablet) HandleQuery(c *mysql.Conn, query string, callback func(*
 	}
 
 	// return the pre-computed results for any schema introspection queries
-	result, ok := globalTabletEnv.schemaQueries[query]
+	result, ok := schemaQueries[query]
 	if ok {
 		return callback(result)
 	}
@@ -491,7 +486,7 @@ func (t *explainTablet) HandleQuery(c *mysql.Conn, query string, callback func(*
 		colTypeMap := map[string]querypb.Type{}
 		for _, table := range tables {
 			tableName := sqlparser.String(table)
-			columns, exists := globalTabletEnv.tableColumns[tableName]
+			columns, exists := tableColumns[tableName]
 			if !exists && tableName != "" && tableName != "dual" {
 				return fmt.Errorf("unable to resolve table name %s", tableName)
 			}
diff --git a/go/vt/vtgate/engine/cached_size.go b/go/vt/vtgate/engine/cached_size.go
index 6343ad62f8..67071b42b7 100644
--- a/go/vt/vtgate/engine/cached_size.go
+++ b/go/vt/vtgate/engine/cached_size.go
@@ -523,7 +523,7 @@ func (cached *Route) CachedSize(alloc bool) int64 {
 	}
 	size := int64(0)
 	if alloc {
-		size += int64(224)
+		size += int64(208)
 	}
 	// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
 	size += cached.Keyspace.CachedSize(true)
@@ -552,23 +552,13 @@ func (cached *Route) CachedSize(alloc bool) int64 {
 	{
 		size += int64(cap(cached.OrderBy)) * int64(32)
 	}
-	// field SysTableTableSchema []vitess.io/vitess/go/vt/vtgate/evalengine.Expr
-	{
-		size += int64(cap(cached.SysTableTableSchema)) * int64(16)
-		for _, elem := range cached.SysTableTableSchema {
-			if cc, ok := elem.(cachedObject); ok {
-				size += cc.CachedSize(true)
-			}
-		}
+	// field SysTableTableSchema vitess.io/vitess/go/vt/vtgate/evalengine.Expr
+	if cc, ok := cached.SysTableTableSchema.(cachedObject); ok {
+		size += cc.CachedSize(true)
 	}
-	// field SysTableTableName []vitess.io/vitess/go/vt/vtgate/evalengine.Expr
-	{
-		size += int64(cap(cached.SysTableTableName)) * int64(16)
-		for _, elem := range cached.SysTableTableName {
-			if cc, ok := elem.(cachedObject); ok {
-				size += cc.CachedSize(true)
-			}
-		}
+	// field SysTableTableName vitess.io/vitess/go/vt/vtgate/evalengine.Expr
+	if cc, ok := cached.SysTableTableName.(cachedObject); ok {
+		size += cc.CachedSize(true)
 	}
 	return size
 }
diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go
index aecc6094c5..9f73a7f39f 100644
--- a/go/vt/vtgate/engine/route.go
+++ b/go/vt/vtgate/engine/route.go
@@ -94,8 +94,8 @@ type Route struct {
 	ScatterErrorsAsWarnings bool
 
 	// The following two fields are used when routing information_schema queries
-	SysTableTableSchema []evalengine.Expr
-	SysTableTableName   []evalengine.Expr
+	SysTableTableSchema evalengine.Expr
+	SysTableTableName   evalengine.Expr
 
 	// Route does not take inputs
 	noInputs
@@ -415,7 +415,7 @@ func (route *Route) routeInfoSchemaQuery(vcursor VCursor, bindVars map[string]*q
 		return destinations, vterrors.Wrapf(err, "failed to find information about keyspace `%s`", ks)
 	}
 
-	if len(route.SysTableTableName) == 0 && len(route.SysTableTableSchema) == 0 {
+	if route.SysTableTableName == nil && route.SysTableTableSchema == nil {
 		return defaultRoute()
 	}
 
@@ -425,38 +425,22 @@ func (route *Route) routeInfoSchemaQuery(vcursor VCursor, bindVars map[string]*q
 	}
 
 	var specifiedKS string
-	for _, tableSchema := range route.SysTableTableSchema {
-		result, err := tableSchema.Evaluate(env)
+	if route.SysTableTableSchema != nil {
+		result, err := route.SysTableTableSchema.Evaluate(env)
 		if err != nil {
 			return nil, err
 		}
-		ks := result.Value().ToString()
-		if specifiedKS == "" {
-			specifiedKS = ks
-		}
-		if specifiedKS != ks {
-			return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "specifying two different database in the query is not supported")
-		}
-	}
-	if specifiedKS != "" {
+		specifiedKS = result.Value().ToString()
 		bindVars[sqltypes.BvSchemaName] = sqltypes.StringBindVariable(specifiedKS)
 	}
 
 	var tableName string
-	for _, sysTableName := range route.SysTableTableName {
-		val, err := sysTableName.Evaluate(env)
+	if route.SysTableTableName != nil {
+		val, err := route.SysTableTableName.Evaluate(env)
 		if err != nil {
 			return nil, err
 		}
-		tabName := val.Value().ToString()
-		if tableName == "" {
-			tableName = tabName
-		}
-		if tableName != tabName {
-			return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "two predicates for table_name not supported")
-		}
-	}
-	if tableName != "" {
+		tableName = val.Value().ToString()
 		bindVars[BvTableName] = sqltypes.StringBindVariable(tableName)
 	}
 
@@ -745,27 +729,11 @@ func (route *Route) description() PrimitiveDescription {
 	if len(route.Values) > 0 {
 		other["Values"] = route.Values
 	}
-	if len(route.SysTableTableSchema) != 0 {
-		sysTabSchema := "["
-		for idx, tableSchema := range route.SysTableTableSchema {
-			if idx != 0 {
-				sysTabSchema += ", "
-			}
-			sysTabSchema += tableSchema.String()
-		}
-		sysTabSchema += "]"
-		other["SysTableTableSchema"] = sysTabSchema
-	}
-	if len(route.SysTableTableName) != 0 {
-		sysTableName := "["
-		for idx, tableName := range route.SysTableTableName {
-			if idx != 0 {
-				sysTableName += ", "
-			}
-			sysTableName += tableName.String()
-		}
-		sysTableName += "]"
-		other["SysTableTableName"] = sysTableName
+	if route.SysTableTableSchema != nil {
+		other["SysTableTableSchema"] = route.SysTableTableSchema.String()
+	}
+	if route.SysTableTableName != nil {
+		other["SysTableTableName"] = route.SysTableTableName.String()
 	}
 	orderBy := GenericJoin(route.OrderBy, orderByToString)
 	if orderBy != "" {
diff --git a/go/vt/vtgate/evalengine/expressions.go b/go/vt/vtgate/evalengine/expressions.go
index a32badee48..baafbe8a0c 100644
--- a/go/vt/vtgate/evalengine/expressions.go
+++ b/go/vt/vtgate/evalengine/expressions.go
@@ -327,3 +327,15 @@ func evaluateByType(val *querypb.BindVariable) (EvalResult, error) {
 func (e *EvalResult) debugString() string {
 	return fmt.Sprintf("(%s) %d %d %f %s", querypb.Type_name[int32(e.typ)], e.ival, e.uval, e.fval, string(e.bytes))
 }
+
+// AreExprEqual checks if the provided Expr are the same or not
+func AreExprEqual(expr1 Expr, expr2 Expr) bool {
+	// Check the types of the two expressions, if they don't match then the two are not equal
+	if fmt.Sprintf("%T", expr1) != fmt.Sprintf("%T", expr2) {
+		return false
+	}
+	if expr1.String() == expr2.String() {
+		return true
+	}
+	return false
+}
diff --git a/go/vt/vtgate/planbuilder/fuzz.go b/go/vt/vtgate/planbuilder/fuzz.go
new file mode 100644
index 0000000000..07fbc9bf33
--- /dev/null
+++ b/go/vt/vtgate/planbuilder/fuzz.go
@@ -0,0 +1,51 @@
+/*
+Copyright 2021 The Vitess Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+// +build gofuzz
+
+package planbuilder
+
+import (
+	"vitess.io/vitess/go/vt/key"
+	topodatapb "vitess.io/vitess/go/vt/proto/topodata"
+	"vitess.io/vitess/go/vt/sqlparser"
+	"vitess.io/vitess/go/vt/vtgate/semantics"
+	"vitess.io/vitess/go/vt/vtgate/vindexes"
+)
+
+var _ semantics.SchemaInformation = (*fakeFuzzSI)(nil)
+
+type fakeFuzzSI struct {
+	tables map[string]*vindexes.Table
+}
+
+// Helper func:
+func (s *fakeFuzzSI) FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.Table, vindexes.Vindex, string, topodatapb.TabletType, key.Destination, error) {
+	return s.tables[sqlparser.String(tablename)], nil, "", 0, nil, nil
+}
+
+// FuzzAnalyse implements the fuzzer
+func FuzzAnalyse(data []byte) int {
+	tree, err := sqlparser.Parse(string(data))
+	if err != nil {
+		return -1
+	}
+	semTable, err := semantics.Analyse(tree, &fakeFuzzSI{})
+	if err != nil {
+		return 0
+	}
+	_, _ = createQGFromSelect(tree.(*sqlparser.Select), semTable)
+	return 1
+}
diff --git a/go/vt/vtgate/planbuilder/route.go b/go/vt/vtgate/planbuilder/route.go
index eaae96a1d5..6f4cb9cba4 100644
--- a/go/vt/vtgate/planbuilder/route.go
+++ b/go/vt/vtgate/planbuilder/route.go
@@ -440,7 +440,23 @@ func (rb *route) JoinCanMerge(pb *primitiveBuilder, rrb *route, ajoin *sqlparser
 		if where == nil {
 			return true
 		}
-		return ajoin != nil
+		tableWithRoutingPredicates := make(map[sqlparser.TableName]struct{})
+		_ = sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {
+			col, ok := node.(*sqlparser.ColName)
+			if ok {
+				hasRuntimeRoutingPredicates := isTableNameCol(col) || isDbNameCol(col)
+				if hasRuntimeRoutingPredicates && pb.st.tables[col.Qualifier] != nil {
+					tableWithRoutingPredicates[col.Qualifier] = struct{}{}
+				}
+			}
+			return true, nil
+		}, where)
+		// Routes can be merged if only 1 table is used in the predicates that are used for routing
+		// TODO :- Even if more table are present in the routing, we can merge if they agree
+		if len(tableWithRoutingPredicates) <= 1 {
+			return true
+		}
+		return len(tableWithRoutingPredicates) == 0
 	}
 	if ajoin == nil {
 		return false
diff --git a/go/vt/vtgate/planbuilder/select.go b/go/vt/vtgate/planbuilder/select.go
index fbf582fc21..962f40b44b 100644
--- a/go/vt/vtgate/planbuilder/select.go
+++ b/go/vt/vtgate/planbuilder/select.go
@@ -97,8 +97,8 @@ func shouldRetryWithCNFRewriting(plan logicalPlan) bool {
 	}
 	// if we have a I_S query, but have not found table_schema or table_name, let's try CNF
 	return routePlan.eroute.Opcode == engine.SelectDBA &&
-		len(routePlan.eroute.SysTableTableName) == 0 &&
-		len(routePlan.eroute.SysTableTableSchema) == 0
+		routePlan.eroute.SysTableTableName == nil &&
+		routePlan.eroute.SysTableTableSchema == nil
 
 }
 
diff --git a/go/vt/vtgate/planbuilder/system_tables.go b/go/vt/vtgate/planbuilder/system_tables.go
index 111d86bb41..1c6e243ef9 100644
--- a/go/vt/vtgate/planbuilder/system_tables.go
+++ b/go/vt/vtgate/planbuilder/system_tables.go
@@ -18,7 +18,9 @@ package planbuilder
 
 import (
 	"vitess.io/vitess/go/sqltypes"
+	vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
 	"vitess.io/vitess/go/vt/sqlparser"
+	"vitess.io/vitess/go/vt/vterrors"
 	"vitess.io/vitess/go/vt/vtgate/engine"
 	"vitess.io/vitess/go/vt/vtgate/evalengine"
 )
@@ -34,9 +36,15 @@ func (pb *primitiveBuilder) findSysInfoRoutingPredicates(expr sqlparser.Expr, ru
 	}
 
 	if isTableSchema {
-		rut.eroute.SysTableTableSchema = append(rut.eroute.SysTableTableSchema, out)
+		if rut.eroute.SysTableTableSchema != nil && !evalengine.AreExprEqual(rut.eroute.SysTableTableSchema, out) {
+			return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "two predicates for specifying the database are not supported")
+		}
+		rut.eroute.SysTableTableSchema = out
 	} else {
-		rut.eroute.SysTableTableName = append(rut.eroute.SysTableTableName, out)
+		if rut.eroute.SysTableTableName != nil && !evalengine.AreExprEqual(rut.eroute.SysTableTableName, out) {
+			return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "two predicates for table_name not supported")
+		}
+		rut.eroute.SysTableTableName = out
 	}
 
 	return nil
diff --git a/go/vt/vttablet/tabletmanager/tm_init.go b/go/vt/vttablet/tabletmanager/tm_init.go
index 8a4f7dd34c..3e615feea3 100644
--- a/go/vt/vttablet/tabletmanager/tm_init.go
+++ b/go/vt/vttablet/tabletmanager/tm_init.go
@@ -171,14 +171,6 @@ type TabletManager struct {
 	// _shardSyncCancel is the function to stop the background shard sync goroutine.
 	_shardSyncCancel context.CancelFunc
 
-	// _rebuildKeyspaceDone is a channel for waiting until the current keyspace
-	// has been rebuilt
-	_rebuildKeyspaceDone chan struct{}
-
-	// _rebuildKeyspaceCancel is the function to stop a keyspace rebuild currently
-	// in progress
-	_rebuildKeyspaceCancel context.CancelFunc
-
 	// _lockTablesConnection is used to get and release the table read locks to pause replication
 	_lockTablesConnection *dbconnpool.DBConnection
 	_lockTablesTimer      *time.Timer
@@ -326,7 +318,6 @@ func (tm *TabletManager) Close() {
 	// rather than registering it as an OnTerm hook so the shard sync loop keeps
 	// running during lame duck.
 	tm.stopShardSync()
-	tm.stopRebuildKeyspace()
 
 	// cleanup initialized fields in the tablet entry
 	f := func(tablet *topodatapb.Tablet) error {
@@ -357,7 +348,6 @@ func (tm *TabletManager) Stop() {
 	// Stop the shard sync loop and wait for it to exit. This needs to be done
 	// here in addition to in Close() because tests do not call Close().
 	tm.stopShardSync()
-	tm.stopRebuildKeyspace()
 
 	if tm.UpdateStream != nil {
 		tm.UpdateStream.Disable()
@@ -396,10 +386,7 @@ func (tm *TabletManager) createKeyspaceShard(ctx context.Context) (*topo.ShardIn
 	case err == nil:
 		tm.tmState.RefreshFromTopoInfo(ctx, nil, srvKeyspace)
 	case topo.IsErrType(err, topo.NoNode):
-		var rebuildKsCtx context.Context
-		rebuildKsCtx, tm._rebuildKeyspaceCancel = context.WithCancel(tm.BatchCtx)
-		tm._rebuildKeyspaceDone = make(chan struct{})
-		go tm.rebuildKeyspace(rebuildKsCtx, tm._rebuildKeyspaceDone, tablet.Keyspace, rebuildKeyspaceRetryInterval)
+		go tm.rebuildKeyspace(tablet.Keyspace, rebuildKeyspaceRetryInterval)
 	default:
 		return nil, vterrors.Wrap(err, "initeKeyspaceShardTopo: failed to read SrvKeyspace")
 	}
@@ -425,50 +412,28 @@ func (tm *TabletManager) createKeyspaceShard(ctx context.Context) (*topo.ShardIn
 	return shardInfo, nil
 }
 
-func (tm *TabletManager) stopRebuildKeyspace() {
-	var doneChan <-chan struct{}
-
-	tm.mutex.Lock()
-	if tm._rebuildKeyspaceCancel != nil {
-		tm._rebuildKeyspaceCancel()
-	}
-	doneChan = tm._rebuildKeyspaceDone
-	tm.mutex.Unlock()
-
-	if doneChan != nil {
-		<-doneChan
-	}
-}
-
-func (tm *TabletManager) rebuildKeyspace(ctx context.Context, done chan<- struct{}, keyspace string, retryInterval time.Duration) {
+func (tm *TabletManager) rebuildKeyspace(keyspace string, retryInterval time.Duration) {
 	var srvKeyspace *topodatapb.SrvKeyspace
-
 	defer func() {
 		log.Infof("Keyspace rebuilt: %v", keyspace)
-		if ctx.Err() == nil {
-			tm.tmState.RefreshFromTopoInfo(tm.BatchCtx, nil, srvKeyspace)
-		}
-		close(done)
+		tm.tmState.RefreshFromTopoInfo(tm.BatchCtx, nil, srvKeyspace)
 	}()
 
 	// RebuildKeyspace will fail until at least one tablet is up for every shard.
 	firstTime := true
 	var err error
 	for {
-		if ctx.Err() != nil {
-			return
-		}
 		if !firstTime {
 			// If keyspace was rebuilt by someone else, we can just exit.
-			srvKeyspace, err = tm.TopoServer.GetSrvKeyspace(ctx, tm.tabletAlias.Cell, keyspace)
-			if err == nil || ctx.Err() != nil {
+			srvKeyspace, err = tm.TopoServer.GetSrvKeyspace(tm.BatchCtx, tm.tabletAlias.Cell, keyspace)
+			if err == nil {
 				return
 			}
 		}
-		err = topotools.RebuildKeyspace(ctx, logutil.NewConsoleLogger(), tm.TopoServer, keyspace, []string{tm.tabletAlias.Cell}, false)
+		err = topotools.RebuildKeyspace(tm.BatchCtx, logutil.NewConsoleLogger(), tm.TopoServer, keyspace, []string{tm.tabletAlias.Cell}, false)
 		if err == nil {
-			srvKeyspace, err = tm.TopoServer.GetSrvKeyspace(ctx, tm.tabletAlias.Cell, keyspace)
-			if err == nil || ctx.Err() != nil {
+			srvKeyspace, err = tm.TopoServer.GetSrvKeyspace(tm.BatchCtx, tm.tabletAlias.Cell, keyspace)
+			if err == nil {
 				return
 			}
 		}


Test patch:
diff --git a/.github/workflows/docker_test_1.yml b/.github/workflows/docker_test_1.yml
index ad1fdf512b..f15e3a3f9b 100644
--- a/.github/workflows/docker_test_1.yml
+++ b/.github/workflows/docker_test_1.yml
@@ -13,19 +13,9 @@ jobs:
       with:
         go-version: 1.13
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
     - name: Run tests which require docker - 1
       run: |
-        go run test.go -docker=true --follow -shard 10
+        go run test.go -docker=true --follow -shard 10
\ No newline at end of file
diff --git a/.github/workflows/docker_test_2.yml b/.github/workflows/docker_test_2.yml
index af1a5258ab..84ea569d5d 100644
--- a/.github/workflows/docker_test_2.yml
+++ b/.github/workflows/docker_test_2.yml
@@ -13,19 +13,9 @@ jobs:
       with:
         go-version: 1.13
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
     - name: Run tests which require docker - 2
       run: |
-        go run test.go -docker=true --follow -shard 25
+        go run test.go -docker=true --follow -shard 25
\ No newline at end of file
diff --git a/.github/workflows/docker_test_3.yml b/.github/workflows/docker_test_3.yml
index 718e01a6ac..92c9e0cbe5 100644
--- a/.github/workflows/docker_test_3.yml
+++ b/.github/workflows/docker_test_3.yml
@@ -13,16 +13,6 @@ jobs:
       with:
         go-version: 1.13
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/e2e_race.yml b/.github/workflows/e2e_race.yml
index 8c596e8556..b6ce479397 100644
--- a/.github/workflows/e2e_race.yml
+++ b/.github/workflows/e2e_race.yml
@@ -12,16 +12,6 @@ jobs:
       with:
         go-version: 1.15
 
-    - name: Tune the OS
-      run: |
-        echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
-
-    # TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
-    - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
-      run: |
-        echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
-    # DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
-
     - name: Check out code
       uses: actions/checkout@v2
 
diff --git a/go/test/endtoend/vtgate/system_schema_test.go b/go/test/endtoend/vtgate/system_schema_test.go
index 8e2f235d34..1a0f3b6340 100644
--- a/go/test/endtoend/vtgate/system_schema_test.go
+++ b/go/test/endtoend/vtgate/system_schema_test.go
@@ -188,29 +188,3 @@ func TestSystemSchemaQueryWithoutQualifier(t *testing.T) {
 	qr3 := exec(t, conn2, queryWithoutQualifier)
 	require.Equal(t, qr2, qr3)
 }
-
-func TestMultipleSchemaPredicates(t *testing.T) {
-	defer cluster.PanicHandler(t)
-	ctx := context.Background()
-	conn, err := mysql.Connect(ctx, &vtParams)
-	require.NoError(t, err)
-	defer conn.Close()
-
-	query := fmt.Sprintf("select t.table_schema,t.table_name,c.column_name,c.column_type "+
-		"from information_schema.tables t "+
-		"join information_schema.columns c "+
-		"on c.table_schema = t.table_schema and c.table_name = t.table_name "+
-		"where t.table_schema = '%s' and c.table_schema = '%s' and c.table_schema = '%s' and c.table_schema = '%s'", KeyspaceName, KeyspaceName, KeyspaceName, KeyspaceName)
-	qr1 := exec(t, conn, query)
-	require.EqualValues(t, 4, len(qr1.Fields))
-
-	// test a query with two keyspace names
-	query = fmt.Sprintf("select t.table_schema,t.table_name,c.column_name,c.column_type "+
-		"from information_schema.tables t "+
-		"join information_schema.columns c "+
-		"on c.table_schema = t.table_schema and c.table_name = t.table_name "+
-		"where t.table_schema = '%s' and c.table_schema = '%s' and c.table_schema = '%s'", KeyspaceName, KeyspaceName, "a")
-	_, err = conn.ExecuteFetch(query, 1000, true)
-	require.Error(t, err)
-	require.Contains(t, err.Error(), "specifying two different database in the query is not supported")
-}
diff --git a/go/test/fuzzing/oss_fuzz_build.sh b/go/test/fuzzing/oss_fuzz_build.sh
index d983ed4b93..167f6769f8 100644
--- a/go/test/fuzzing/oss_fuzz_build.sh
+++ b/go/test/fuzzing/oss_fuzz_build.sh
@@ -14,24 +14,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [ "$SANITIZER" = "coverage" ]
-then
-        # As of now Vitess cannot be compiled with coverage sanitizer
-        exit 0
-fi
-
 compile_go_fuzzer ./go/test/fuzzing Fuzz vtctl_fuzzer
 compile_go_fuzzer ./go/test/fuzzing FuzzIsDML is_dml_fuzzer
 compile_go_fuzzer ./go/test/fuzzing FuzzNormalizer normalizer_fuzzer
 compile_go_fuzzer ./go/test/fuzzing FuzzParser parser_fuzzer
 
+#cp ./go/test/fuzzing/mysql/mysql_fuzzer.go ./go/mysql/
 compile_go_fuzzer ./go/mysql FuzzWritePacket write_packet_fuzzer
 compile_go_fuzzer ./go/mysql FuzzHandleNextCommand handle_next_command_fuzzer
 compile_go_fuzzer ./go/mysql FuzzReadQueryResults read_query_results_fuzzer
 
-
-compile_go_fuzzer ./go/mysql FuzzTLSServer fuzz_tls
-compile_go_fuzzer ./go/vt/vtgate/grpcvtgateconn Fuzz grpc_vtgate_fuzzer
-
 # Build dictionaries
 cp $SRC/vitess/go/test/fuzzing/vtctl_fuzzer.dict $OUT/
diff --git a/go/vt/vtexplain/vtexplain_vttablet_test.go b/go/vt/vtexplain/vtexplain_vttablet_test.go
index 60e5b45791..9710e11623 100644
--- a/go/vt/vtexplain/vtexplain_vttablet_test.go
+++ b/go/vt/vtexplain/vtexplain_vttablet_test.go
@@ -67,8 +67,7 @@ create table test_partitioned (
 	if err != nil {
 		t.Fatalf("parseSchema: %v", err)
 	}
-
-	globalTabletEnv, _ = newTabletEnvironment(ddls, defaultTestOpts())
+	initTabletEnvironment(ddls, defaultTestOpts())
 
 	tablet := newTablet(defaultTestOpts(), &topodatapb.Tablet{
 		Keyspace: "test_keyspace",
@@ -140,8 +139,7 @@ create table t1 like t2;
 	if err != nil {
 		t.Fatalf("parseSchema: %v", err)
 	}
-
-	_, err = newTabletEnvironment(ddl, defaultTestOpts())
+	err = initTabletEnvironment(ddl, defaultTestOpts())
 	if err.Error() != expected {
 		t.Errorf("want: %s, got %s", expected, err.Error())
 	}
diff --git a/go/vt/vtgate/engine/route_test.go b/go/vt/vtgate/engine/route_test.go
index 5ee46debfa..67afadce4c 100644
--- a/go/vt/vtgate/engine/route_test.go
+++ b/go/vt/vtgate/engine/route_test.go
@@ -77,24 +77,23 @@ func TestSelectUnsharded(t *testing.T) {
 }
 
 func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T) {
-	stringListToExprList := func(in []string) []evalengine.Expr {
-		var schema []evalengine.Expr
-		for _, s := range in {
-			schema = append(schema, evalengine.NewLiteralString([]byte(s)))
+	stringToExpr := func(in string) evalengine.Expr {
+		var schema evalengine.Expr
+		if in != "" {
+			schema = evalengine.NewLiteralString([]byte(in))
 		}
 		return schema
 	}
 
 	type testCase struct {
-		tableSchema, tableName []string
-		testName               string
-		expectedLog            []string
-		routed                 bool
+		tableSchema, tableName, testName string
+		expectedLog                      []string
+		routed                           bool
 	}
 	tests := []testCase{{
 		testName:    "both schema and table predicates - routed table",
-		tableSchema: []string{"schema"},
-		tableName:   []string{"table"},
+		tableSchema: "schema",
+		tableName:   "table",
 		routed:      true,
 		expectedLog: []string{
 			"FindTable(`schema`.`table`)",
@@ -102,17 +101,8 @@ func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T)
 			"ExecuteMultiShard routedKeyspace.1: dummy_select {__replacevtschemaname: type:INT64 value:\"1\" __vttablename: type:VARBINARY value:\"routedTable\" } false false"},
 	}, {
 		testName:    "both schema and table predicates - not routed",
-		tableSchema: []string{"schema"},
-		tableName:   []string{"table"},
-		routed:      false,
-		expectedLog: []string{
-			"FindTable(`schema`.`table`)",
-			"ResolveDestinations schema [] Destinations:DestinationAnyShard()",
-			"ExecuteMultiShard schema.1: dummy_select {__replacevtschemaname: type:INT64 value:\"1\" __vttablename: type:VARBINARY value:\"table\" } false false"},
-	}, {
-		testName:    "multiple schema and table predicates",
-		tableSchema: []string{"schema", "schema", "schema"},
-		tableName:   []string{"table", "table", "table"},
+		tableSchema: "schema",
+		tableName:   "table",
 		routed:      false,
 		expectedLog: []string{
 			"FindTable(`schema`.`table`)",
@@ -120,7 +110,7 @@ func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T)
 			"ExecuteMultiShard schema.1: dummy_select {__replacevtschemaname: type:INT64 value:\"1\" __vttablename: type:VARBINARY value:\"table\" } false false"},
 	}, {
 		testName:  "table name predicate - routed table",
-		tableName: []string{"tableName"},
+		tableName: "tableName",
 		routed:    true,
 		expectedLog: []string{
 			"FindTable(tableName)",
@@ -128,7 +118,7 @@ func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T)
 			"ExecuteMultiShard routedKeyspace.1: dummy_select {__vttablename: type:VARBINARY value:\"routedTable\" } false false"},
 	}, {
 		testName:  "table name predicate - not routed",
-		tableName: []string{"tableName"},
+		tableName: "tableName",
 		routed:    false,
 		expectedLog: []string{
 			"FindTable(tableName)",
@@ -136,13 +126,7 @@ func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T)
 			"ExecuteMultiShard ks.1: dummy_select {__vttablename: type:VARBINARY value:\"tableName\" } false false"},
 	}, {
 		testName:    "schema predicate",
-		tableSchema: []string{"myKeyspace"},
-		expectedLog: []string{
-			"ResolveDestinations myKeyspace [] Destinations:DestinationAnyShard()",
-			"ExecuteMultiShard myKeyspace.1: dummy_select {__replacevtschemaname: type:INT64 value:\"1\" } false false"},
-	}, {
-		testName:    "multiple schema predicates",
-		tableSchema: []string{"myKeyspace", "myKeyspace", "myKeyspace", "myKeyspace"},
+		tableSchema: "myKeyspace",
 		expectedLog: []string{
 			"ResolveDestinations myKeyspace [] Destinations:DestinationAnyShard()",
 			"ExecuteMultiShard myKeyspace.1: dummy_select {__replacevtschemaname: type:INT64 value:\"1\" } false false"},
@@ -163,8 +147,8 @@ func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T)
 				},
 				Query:               "dummy_select",
 				FieldQuery:          "dummy_select_field",
-				SysTableTableSchema: stringListToExprList(tc.tableSchema),
-				SysTableTableName:   stringListToExprList(tc.tableName),
+				SysTableTableSchema: stringToExpr(tc.tableSchema),
+				SysTableTableName:   stringToExpr(tc.tableName),
 			}
 			vc := &loggingVCursor{
 				shards:  []string{"1"},
diff --git a/go/vt/vtgate/executor_select_test.go b/go/vt/vtgate/executor_select_test.go
index f69fc4a9e5..8025ac9e57 100644
--- a/go/vt/vtgate/executor_select_test.go
+++ b/go/vt/vtgate/executor_select_test.go
@@ -2321,7 +2321,7 @@ func TestSelectFromInformationSchema(t *testing.T) {
 	// check failure when trying to query two keyspaces
 	_, err := exec(executor, session, "SELECT B.TABLE_NAME FROM INFORMATION_SCHEMA.TABLES AS A, INFORMATION_SCHEMA.COLUMNS AS B WHERE A.TABLE_SCHEMA = 'TestExecutor' AND A.TABLE_SCHEMA = 'TestXBadSharding'")
 	require.Error(t, err)
-	require.Contains(t, err.Error(), "specifying two different database in the query is not supported")
+	require.Contains(t, err.Error(), "two predicates for specifying the database are not supported")
 
 	// we pick a keyspace and query for table_schema = database(). should be routed to the picked keyspace
 	session.TargetString = "TestExecutor"
diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
index 83d978351c..a04993f162 100644
--- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
@@ -1753,21 +1753,7 @@ Gen4 plan same as above
 
 # query trying to query two different keyspaces at the same time
 "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'"
-{
-  "QueryType": "SELECT",
-  "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'",
-  "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectDBA",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
-    "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_SCHEMA = :__vtschemaname",
-    "SysTableTableSchema": "[VARBINARY(\"user\"), VARBINARY(\"main\")]"
-  }
-}
+"two predicates for specifying the database are not supported"
 
 # information_schema query using database() func
 "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()"
@@ -1800,7 +1786,7 @@ Gen4 plan same as above
     },
     "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
     "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname",
-    "SysTableTableSchema": "[VARBINARY(\"ks\")]"
+    "SysTableTableSchema": "VARBINARY(\"ks\")"
   }
 }
 
@@ -1835,8 +1821,8 @@ Gen4 plan same as above
     },
     "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
     "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :__vttablename",
-    "SysTableTableName": "[VARBINARY(\"route1\")]",
-    "SysTableTableSchema": "[VARBINARY(\"ks\")]"
+    "SysTableTableName": "VARBINARY(\"route1\")",
+    "SysTableTableSchema": "VARBINARY(\"ks\")"
   }
 }
 
@@ -1854,7 +1840,7 @@ Gen4 plan same as above
     },
     "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
     "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and other_column = 42",
-    "SysTableTableSchema": "[VARBINARY(\"ks\")]"
+    "SysTableTableSchema": "VARBINARY(\"ks\")"
   }
 }
 
@@ -1936,6 +1922,6 @@ Gen4 plan same as above
     },
     "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
     "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and (other_column = 42 or TABLE_SCHEMA = 'ks') and (other_column = 42 or foobar = 'value')",
-    "SysTableTableSchema": "[VARBINARY(\"ks\")]"
+    "SysTableTableSchema": "VARBINARY(\"ks\")"
   }
 }
diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt
index b623ae4549..50b3be4af1 100644
--- a/go/vt/vtgate/planbuilder/testdata/from_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/from_cases.txt
@@ -2364,15 +2364,34 @@ Gen4 plan same as above
   "QueryType": "SELECT",
   "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'",
   "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectDBA",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk on rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name where 1 != 1",
-    "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk on rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = :__vttablename and rc.constraint_schema = database() and rc.table_name = :__vttablename",
-    "SysTableTableName": "[VARBINARY(\":vtg1\"), VARBINARY(\":vtg1\")]"
+    "OperatorType": "Join",
+    "Variant": "Join",
+    "JoinColumnIndexes": "1,2,3,4,-1,-2",
+    "TableName": "_",
+    "Inputs": [
+      {
+        "OperatorType": "Route",
+        "Variant": "SelectDBA",
+        "Keyspace": {
+          "Name": "main",
+          "Sharded": false
+        },
+        "FieldQuery": "select rc.update_rule as on_update, rc.delete_rule as on_delete, rc.constraint_schema, rc.constraint_name from information_schema.referential_constraints as rc where 1 != 1",
+        "Query": "select rc.update_rule as on_update, rc.delete_rule as on_delete, rc.constraint_schema, rc.constraint_name from information_schema.referential_constraints as rc where rc.constraint_schema = database() and rc.table_name = :__vttablename",
+        "SysTableTableName": "VARBINARY(\":vtg1\")"
+      },
+      {
+        "OperatorType": "Route",
+        "Variant": "SelectDBA",
+        "Keyspace": {
+          "Name": "main",
+          "Sharded": false
+        },
+        "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name` from information_schema.key_column_usage as fk where 1 != 1",
+        "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name` from information_schema.key_column_usage as fk where fk.constraint_schema = :rc_constraint_schema and fk.constraint_name = :rc_constraint_name and fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = :__vttablename",
+        "SysTableTableName": "VARBINARY(\":vtg1\")"
+      }
+    ]
   }
 }
 
@@ -2390,7 +2409,7 @@ Gen4 plan same as above
     },
     "FieldQuery": "select * from information_schema.schemata where 1 != 1",
     "Query": "select * from information_schema.schemata where schema_name = :__vtschemaname",
-    "SysTableTableSchema": "[VARBINARY(\"user\")]"
+    "SysTableTableSchema": "VARBINARY(\"user\")"
   }
 }
 
@@ -2408,8 +2427,8 @@ Gen4 plan same as above
     },
     "FieldQuery": "select table_comment from information_schema.`tables` where 1 != 1",
     "Query": "select table_comment from information_schema.`tables` where table_schema = :__vtschemaname and table_name = :__vttablename",
-    "SysTableTableName": "[VARBINARY(\"table_name\")]",
-    "SysTableTableSchema": "[VARBINARY(\"schema_name\")]"
+    "SysTableTableName": "VARBINARY(\"table_name\")",
+    "SysTableTableSchema": "VARBINARY(\"schema_name\")"
   }
 }
 
@@ -2419,16 +2438,36 @@ Gen4 plan same as above
   "QueryType": "SELECT",
   "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'",
   "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectDBA",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk on rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name where 1 != 1",
-    "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk on rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name where fk.referenced_column_name is not null and fk.table_schema = :__vtschemaname and fk.table_name = :__vttablename and rc.constraint_schema = :__vtschemaname and rc.table_name = :__vttablename",
-    "SysTableTableName": "[VARBINARY(\"table_name\"), VARBINARY(\"table_name\")]",
-    "SysTableTableSchema": "[VARBINARY(\"table_schema\"), VARBINARY(\"table_schema\")]"
+    "OperatorType": "Join",
+    "Variant": "Join",
+    "JoinColumnIndexes": "1,2,3,4,-1,-2",
+    "TableName": "_",
+    "Inputs": [
+      {
+        "OperatorType": "Route",
+        "Variant": "SelectDBA",
+        "Keyspace": {
+          "Name": "main",
+          "Sharded": false
+        },
+        "FieldQuery": "select rc.update_rule as on_update, rc.delete_rule as on_delete, rc.constraint_schema, rc.constraint_name from information_schema.referential_constraints as rc where 1 != 1",
+        "Query": "select rc.update_rule as on_update, rc.delete_rule as on_delete, rc.constraint_schema, rc.constraint_name from information_schema.referential_constraints as rc where rc.constraint_schema = :__vtschemaname and rc.table_name = :__vttablename",
+        "SysTableTableName": "VARBINARY(\"table_name\")",
+        "SysTableTableSchema": "VARBINARY(\"table_schema\")"
+      },
+      {
+        "OperatorType": "Route",
+        "Variant": "SelectDBA",
+        "Keyspace": {
+          "Name": "main",
+          "Sharded": false
+        },
+        "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name` from information_schema.key_column_usage as fk where 1 != 1",
+        "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name` from information_schema.key_column_usage as fk where fk.constraint_schema = :rc_constraint_schema and fk.constraint_name = :rc_constraint_name and fk.referenced_column_name is not null and fk.table_schema = :__vtschemaname and fk.table_name = :__vttablename",
+        "SysTableTableName": "VARBINARY(\"table_name\")",
+        "SysTableTableSchema": "VARBINARY(\"table_schema\")"
+      }
+    ]
   }
 }
 
@@ -2438,16 +2477,35 @@ Gen4 plan same as above
   "QueryType": "SELECT",
   "Original": "SELECT cc.constraint_name AS 'name', cc.check_clause AS 'expression' FROM information_schema.check_constraints cc JOIN information_schema.table_constraints tc USING (constraint_schema, constraint_name) WHERE tc.table_schema = 'table_schema' AND tc.table_name = 'table_name' AND cc.constraint_schema = 'constraint_schema'",
   "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectDBA",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc join information_schema.table_constraints as tc on cc.constraint_schema = tc.constraint_schema and cc.constraint_name = tc.constraint_name where 1 != 1",
-    "Query": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc join information_schema.table_constraints as tc on cc.constraint_schema = tc.constraint_schema and cc.constraint_name = tc.constraint_name where tc.table_schema = :__vtschemaname and tc.table_name = :__vttablename and cc.constraint_schema = :__vtschemaname",
-    "SysTableTableName": "[VARBINARY(\"table_name\")]",
-    "SysTableTableSchema": "[VARBINARY(\"table_schema\"), VARBINARY(\"constraint_schema\")]"
+    "OperatorType": "Join",
+    "Variant": "Join",
+    "JoinColumnIndexes": "-1,-2",
+    "TableName": "_",
+    "Inputs": [
+      {
+        "OperatorType": "Route",
+        "Variant": "SelectDBA",
+        "Keyspace": {
+          "Name": "main",
+          "Sharded": false
+        },
+        "FieldQuery": "select cc.constraint_name as `name`, cc.check_clause as expression, cc.constraint_schema from information_schema.check_constraints as cc where 1 != 1",
+        "Query": "select cc.constraint_name as `name`, cc.check_clause as expression, cc.constraint_schema from information_schema.check_constraints as cc where cc.constraint_schema = :__vtschemaname",
+        "SysTableTableSchema": "VARBINARY(\"constraint_schema\")"
+      },
+      {
+        "OperatorType": "Route",
+        "Variant": "SelectDBA",
+        "Keyspace": {
+          "Name": "main",
+          "Sharded": false
+        },
+        "FieldQuery": "select 1 from information_schema.table_constraints as tc where 1 != 1",
+        "Query": "select 1 from information_schema.table_constraints as tc where tc.constraint_schema = :cc_constraint_schema and tc.constraint_name = :cc_constraint_name and tc.table_schema = :__vtschemaname and tc.table_name = :__vttablename",
+        "SysTableTableName": "VARBINARY(\"table_name\")",
+        "SysTableTableSchema": "VARBINARY(\"table_schema\")"
+      }
+    ]
   }
 }
 
@@ -2465,8 +2523,8 @@ Gen4 plan same as above
     },
     "FieldQuery": "select column_name from information_schema.statistics where 1 != 1",
     "Query": "select column_name from information_schema.statistics where index_name = 'PRIMARY' and table_schema = :__vtschemaname and table_name = :__vttablename order by seq_in_index asc",
-    "SysTableTableName": "[VARBINARY(\"table_name\")]",
-    "SysTableTableSchema": "[VARBINARY(\"table_schema\")]"
+    "SysTableTableName": "VARBINARY(\"table_name\")",
+    "SysTableTableSchema": "VARBINARY(\"table_schema\")"
   }
 }
 
@@ -2484,8 +2542,8 @@ Gen4 plan same as above
     },
     "FieldQuery": "select generation_expression from information_schema.`columns` where 1 != 1",
     "Query": "select generation_expression from information_schema.`columns` where table_schema = :__vtschemaname and table_name = :__vttablename and column_name = 'column_name'",
-    "SysTableTableName": "[VARBINARY(\"table_name\")]",
-    "SysTableTableSchema": "[VARBINARY(\"table_schema\")]"
+    "SysTableTableName": "VARBINARY(\"table_name\")",
+    "SysTableTableSchema": "VARBINARY(\"table_schema\")"
   }
 }
 
@@ -2520,7 +2578,7 @@ Gen4 plan same as above
     },
     "FieldQuery": "select table_name from (select * from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1",
     "Query": "select table_name from (select * from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery",
-    "SysTableTableSchema": "[VARBINARY(\"table_schema\")]"
+    "SysTableTableSchema": "VARBINARY(\"table_schema\")"
   }
 }
 
@@ -2538,8 +2596,8 @@ Gen4 plan same as above
     },
     "FieldQuery": "select table_name from (select * from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1",
     "Query": "select table_name from (select * from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery where _subquery.table_type = 'table_type' and _subquery.table_name = :__vttablename",
-    "SysTableTableName": "[VARBINARY(\"table_name\")]",
-    "SysTableTableSchema": "[VARBINARY(\"table_schema\")]"
+    "SysTableTableName": "VARBINARY(\"table_name\")",
+    "SysTableTableSchema": "VARBINARY(\"table_schema\")"
   }
 }
 
@@ -2557,7 +2615,7 @@ Gen4 plan same as above
     },
     "FieldQuery": "select cc.constraint_name as `name` from information_schema.check_constraints as cc where 1 != 1",
     "Query": "select cc.constraint_name as `name` from information_schema.check_constraints as cc where cc.constraint_schema = :__vtschemaname and cc.table_schema = :__vtschemaname",
-    "SysTableTableSchema": "[VARBINARY(\"a\"), VARBINARY(\"a\")]"
+    "SysTableTableSchema": "VARBINARY(\"a\")"
   }
 }
 
@@ -2575,7 +2633,7 @@ Gen4 plan same as above
     },
     "FieldQuery": "select COUNT(*) from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
     "Query": "select COUNT(*) from INFORMATION_SCHEMA.`TABLES` where table_schema = :__vtschemaname and table_name = :__vttablename",
-    "SysTableTableName": "[VARBINARY(\"foo\")]",
-    "SysTableTableSchema": "[VARBINARY(\"performance_schema\")]"
+    "SysTableTableName": "VARBINARY(\"foo\")",
+    "SysTableTableSchema": "VARBINARY(\"performance_schema\")"
   }
 }
diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.txt b/go/vt/vtgate/planbuilder/testdata/select_cases.txt
index 503e2d6b40..eed0ee84d6 100644
--- a/go/vt/vtgate/planbuilder/testdata/select_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/select_cases.txt
@@ -1699,8 +1699,8 @@ Gen4 plan same as above
     },
     "FieldQuery": "select DELETE_RULE, UPDATE_RULE from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where 1 != 1",
     "Query": "select DELETE_RULE, UPDATE_RULE from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :__vttablename and KCU.COLUMN_NAME = 'id' and KCU.REFERENCED_TABLE_SCHEMA = 'test' and KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc",
-    "SysTableTableName": "[VARBINARY(\"data_type_table\")]",
-    "SysTableTableSchema": "[VARBINARY(\"test\")]"
+    "SysTableTableName": "VARBINARY(\"data_type_table\")",
+    "SysTableTableSchema": "VARBINARY(\"test\")"
   }
 }
 
@@ -1724,8 +1724,8 @@ Gen4 plan same as above
         },
         "FieldQuery": "select KCU.DELETE_RULE from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where 1 != 1",
         "Query": "select KCU.DELETE_RULE from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :__vttablename and KCU.TABLE_NAME = :__vttablename order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc",
-        "SysTableTableName": "[VARBINARY(\"data_type_table\"), VARBINARY(\"data_type_table\")]",
-        "SysTableTableSchema": "[VARBINARY(\"test\")]"
+        "SysTableTableName": "VARBINARY(\"data_type_table\")",
+        "SysTableTableSchema": "VARBINARY(\"test\")"
       },
       {
         "OperatorType": "Route",
@@ -1736,8 +1736,8 @@ Gen4 plan same as above
         },
         "FieldQuery": "select S.UPDATE_RULE from INFORMATION_SCHEMA.K as S where 1 != 1",
         "Query": "select S.UPDATE_RULE from INFORMATION_SCHEMA.K as S where S.TABLE_SCHEMA = :__vtschemaname and S.TABLE_NAME = :__vttablename",
-        "SysTableTableName": "[VARBINARY(\"sc\")]",
-        "SysTableTableSchema": "[VARBINARY(\"test\")]"
+        "SysTableTableName": "VARBINARY(\"sc\")",
+        "SysTableTableSchema": "VARBINARY(\"test\")"
       }
     ]
   }
@@ -1757,7 +1757,7 @@ Gen4 plan same as above
     },
     "FieldQuery": "select routine_name as `name`, routine_definition as definition from information_schema.routines where 1 != 1",
     "Query": "select routine_name as `name`, routine_definition as definition from information_schema.routines where ROUTINE_SCHEMA = :__vtschemaname and ROUTINE_TYPE = 'PROCEDURE'",
-    "SysTableTableSchema": "[:v1]"
+    "SysTableTableSchema": ":v1"
   }
 }
 
@@ -1775,7 +1775,7 @@ Gen4 plan same as above
     },
     "FieldQuery": "select SUM(data_length + index_length) as size from information_schema.`TABLES` where 1 != 1",
     "Query": "select SUM(data_length + index_length) as size from information_schema.`TABLES` where table_schema = :__vtschemaname",
-    "SysTableTableSchema": "[:v1]"
+    "SysTableTableSchema": ":v1"
   }
 }
 
@@ -1785,14 +1785,34 @@ Gen4 plan same as above
   "QueryType": "SELECT",
   "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position",
   "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectDBA",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu join information_schema.referential_constraints as rc on kcu.constraint_name = rc.constraint_name where 1 != 1",
-    "Query": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu join information_schema.referential_constraints as rc on kcu.constraint_name = rc.constraint_name where kcu.table_schema = :__vtschemaname and rc.constraint_schema = :__vtschemaname and kcu.referenced_column_name is not null order by ordinal_position asc",
-    "SysTableTableSchema": "[:v1, :v2]"
+    "OperatorType": "Join",
+    "Variant": "Join",
+    "JoinColumnIndexes": "-1,-2,-3,-4,-5,-6,1,2",
+    "TableName": "_",
+    "Inputs": [
+      {
+        "OperatorType": "Route",
+        "Variant": "SelectDBA",
+        "Keyspace": {
+          "Name": "main",
+          "Sharded": false
+        },
+        "FieldQuery": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name from information_schema.key_column_usage as kcu where 1 != 1",
+        "Query": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name from information_schema.key_column_usage as kcu where kcu.table_schema = :__vtschemaname and kcu.referenced_column_name is not null order by ordinal_position asc",
+        "SysTableTableSchema": ":v1"
+      },
+      {
+        "OperatorType": "Route",
+        "Variant": "SelectDBA",
+        "Keyspace": {
+          "Name": "main",
+          "Sharded": false
+        },
+        "FieldQuery": "select rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.referential_constraints as rc where 1 != 1",
+        "Query": "select rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.referential_constraints as rc where rc.constraint_name = :kcu_constraint_name and rc.constraint_schema = :__vtschemaname",
+        "SysTableTableSchema": ":v2"
+      }
+    ]
   }
 }
+
diff --git a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
index 472f937a5b..eab094f308 100644
--- a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
@@ -423,23 +423,8 @@ Gen4 plan same as above
 "INTO is not supported on sharded keyspace"
 
 # unsupported two predicates specifying the database for the same table if they are different
-# will fail on run time but will pass on the planbuilder
 "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc  WHERE cc.constraint_schema = 'constraint_schema' AND cc.table_schema = 'a'"
-{
-  "QueryType": "SELECT",
-  "Original": "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc  WHERE cc.constraint_schema = 'constraint_schema' AND cc.table_schema = 'a'",
-  "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectDBA",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select cc.constraint_name as `name` from information_schema.check_constraints as cc where 1 != 1",
-    "Query": "select cc.constraint_name as `name` from information_schema.check_constraints as cc where cc.constraint_schema = :__vtschemaname and cc.table_schema = :__vtschemaname",
-    "SysTableTableSchema": "[VARBINARY(\"constraint_schema\"), VARBINARY(\"a\")]"
-  }
-}
+"two predicates for specifying the database are not supported"
 
 # create view with Cannot auto-resolve for cross-shard joins
 "create view user.view_a as select col from user join user_extra"