Conversation
go/vt/vtgate/router.go
Outdated
| func (rtr *Router) handlePrimary(vcursor *queryExecutor, vindexKey interface{}, colVindex *vindexes.ColumnVindex, bv map[string]interface{}, rowNum int) (ksid []byte, err error) { | ||
| if vindexKey == nil { | ||
| func (rtr *Router) handlePrimary(vcursor *queryExecutor, vindexKeys []interface{}, colVindex *vindexes.ColumnVindex, bv map[string]interface{}, allShards []*topodatapb.ShardReference) (keyspaceIDs [][]byte, err error) { | ||
| if vindexKeys == nil { |
There was a problem hiding this comment.
I don't think this is possible. Were you able to get coverage to trigger this path?
go/vt/vtgate/router.go
Outdated
| func (rtr *Router) handleNonPrimary(vcursor *queryExecutor, vindexKeys []interface{}, colVindex *vindexes.ColumnVindex, bv map[string]interface{}, ksids [][]byte) error { | ||
| if colVindex.Owned { | ||
| if vindexKey == nil { | ||
| if vindexKeys == nil { |
There was a problem hiding this comment.
This should also not be possible.
|
Nice work. Only couple of comments. |
|
Removed the redundant code in the latest commit. coverage: 82.8% of statements coverage: 80.3% of statements coverage: 98.4% of statements |
sougou
left a comment
There was a problem hiding this comment.
I did a full code coverage analysis. Found test cases missing in a few places. Some of these tests have been missing from before. But it's better to add them now, so we don't regret later.
The general philosophy is that, if it can happen in production, then we need that code to be covered. There are a few errors that are impossible because there's higher level sanity checking. It's ok if those paths are not covered.
| return false, fmt.Errorf("Binary.Verify: %v", err) | ||
| } | ||
| if bytes.Compare(data, ksids[rowNum]) != 0 { | ||
| return false, nil |
There was a problem hiding this comment.
Needs test case. Same with all other vindexes that have similar code.
| return vind.lkp.Verify(vcursor, id, ksid) | ||
| // Verify returns true if ids maps to ksids. | ||
| func (vind *LookupHashUnique) Verify(vcursor VCursor, ids []interface{}, ksids [][]byte) (bool, error) { | ||
| return vind.lkp.Verify(vcursor, ids, ksids) |
There was a problem hiding this comment.
Needs test case. Same with the rest of the functions.
| t := m["table"] | ||
| from := m["from"] | ||
| to := m["to"] | ||
| func (lkp *lookup) Init(lookupQueryParams map[string]string, isHashed bool) { |
There was a problem hiding this comment.
Many functions in this file are missing critical code coverage. It's probably an artifact of previous changes.
go/vt/vtgate/engine/route.go
Outdated
| return err | ||
| } | ||
| if vindexKey == nil { | ||
| if vindexKeys == nil { |
| vindexKey, err = reversible.ReverseMap(vcursor, ksid) | ||
| vindexKeys, err = reversible.ReverseMap(vcursor, reverseKsids) | ||
| if err != nil { | ||
| return err |
There was a problem hiding this comment.
Missing test case for this. Is this possible?
|
@sougou : Added corresponding positive as well as negative test-cases for all the vindexes. Please take a look |
Our internal implementation of Locate() does not support to be called from init(). Therefore, I've changed the test to create a new vindex in each test instance. I've also added error checking for the creation of the vindex to make sure we don't swallow any errors. I've fixed this code before in commit 1bcbff7 but I forgot to add a proper warning in the code to make sure that it doesn't happen again. Therefore, the same issue was introduced in vitessio#2422. With the new warning, people should no longer eagerly revert it back to a global variable :)
* 'master' of https://github.com/youtube/vitess: (220 commits) vtgate/vindexes: Do not run testfiles.Locate() from init() (2nd time). Add comment to document when new fields are included in response publish site Fri Jan 6 08:02:30 PST 2017 Updating doc. Optionally send additional C API fields through in responses Fixing explorer to handle empty files. MultiRow Insert Optimization (vitessio#2422) Now the local examples use 'zk2' topology. Adding Consul 0.7.2 to base docker image. etcd2topo: using lease ID in lock filenames. Implementing the Consul topology client. test: vtgate_buffer.py: Add second test for vtctl TabletExternallyReparented. test: vtgate_buffer.py: Stop the the two threads in case of a test error. test: vtgate_buffer.py: Move setup code from setUp to setUpModule. test: Add "demote_master_commands" to MysqlFlavor class. Include on clauses in impossible queries, to avoid only_full_group_by in aggregations with joins (vitessio#2433) Adds support for parsing queries with boolean value comparisons, i.e. true/false and =, !=, >, <, >=, <= (vitessio#2432) V3 Engine Code Refactor (vitessio#2423) Refactor impossible query generation, and support group by - (vitessio#2409) docker/test/run: Avoid using non-universal --tmpdir flag on mktemp (vitessio#2429) ...
This Pull request contains the changes for Optimising the vindex based queries on look-up shard for Multi-Row Insert.
@sougou , Please take a look.