Overview of the Issue
When insert query is targeted to a specific shard but the inserted row's shard key doesn't fall on the provided shard, insert operation succeeds but when you query back the inserted records and provide the correct shard keys, Vitess doesn't return any results.
Reproduction Steps
Steps to reproduce this issue, example:
-
Deploy the following vschema:
{
"sharded": true,
"vindexes": {
"hash": {
"type": "hash"
},
"tables": {
"user": {
"column_vindexes": [
{
"column": "user_id",
"name": "hash"
}
]
}
}
}
-
Deploy the following schema:
create table user(user_id bigint, name varchar(128), primary key(user_id));
-
Run the following on a specific shard. The insert will succeed.
INSERT INTO user VALUES (1, "John"), (2, "Henry"), (3, "Mary")
In my test, this was done using the gRPC protocol and setting the target as the shard reference rather than the keyspace. Note that, in this case, the provided shard would not be the shard where these rows would have been added if they were inserted to a keyspace instead. This incorrect shard was chosen to test what happens, if someone accidentally inserted data into the wrong shard.
-
When you query the keyspace by providing the correct shard key, vitess will return no results.
SELECT * FROM user where user_id=1
OUTPUT: No Rows Found
Binary version
Example:
giaquinti@workspace:~$ vtgate --version
vitess@2b9076b45a1f:/vt/local$ vtgate -version
ERROR: logging before flag.Parse: E0921 22:12:18.896672 2193 syslogger.go:149] can't connect to syslog
Version: 10.0.0-RC1 (Git revision d3313e6ac branch 'master') built on Fri Apr 23 23:11:30 UTC 2021 by vitess@dd80b143c8eb using go1.15.6 linux/amd64```
#### Operating system and Environment details
OS, Architecture, and any other information you can provide
about the environment.
- Operating system (output of `cat /etc/os-release`):
```vitess@2b9076b45a1f:/vt/local$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"```
- Kernel version (output of `uname -sr`):
```vitess@2b9076b45a1f:/vt/local$ uname -sr
Linux 5.10.25-linuxkit```
- Architecture (output of `uname -m`):
```vitess@2b9076b45a1f:/vt/local$ uname -m
x86_64```
#### Log Fragments
NA
Include appropriate log fragments. If the log is longer than a few dozen lines, please
include the URL to the [gist](https://gist.github.com/) of the log instead of posting it in the issue.
Overview of the Issue
When
insertquery is targeted to a specific shard but the inserted row's shard key doesn't fall on the provided shard, insert operation succeeds but when you query back the inserted records and provide the correct shard keys, Vitess doesn't return any results.Reproduction Steps
Steps to reproduce this issue, example:
Deploy the following
vschema:Deploy the following
schema:Run the following on a specific shard. The insert will succeed.
In my test, this was done using the gRPC protocol and setting the
targetas the shard reference rather than the keyspace. Note that, in this case, the provided shard would not be the shard where these rows would have been added if they were inserted to a keyspace instead. This incorrect shard was chosen to test what happens, if someone accidentally inserted data into the wrong shard.When you query the keyspace by providing the correct shard key, vitess will return no results.
OUTPUT: No Rows Found
Binary version
Example: