vtexplain support different modes #3532
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add an optional execution mode option to vtexplain with support for "multi" (default), "legacy_autocommit", and "twopc" to provide more insight into how vitess will handle queries in these other non-standard modes.
In doing this work I noticed that delete queries were failing on tables with an owned lookup vindex, because vtgate tries to run a
select ... for update
query on the primary table to find out the values needed to delete the corresponding rows in the lookup table.As an attempt to make this work, I updated the vtgate query planner with an option to run the lookup queries in an unlocked mode and use this mode when legacy autocommit is enable and there is no active transaction (see 3edb1bfafd7210040b65b25ae05f25880984338f for the implementation). Although this is clearly not transactionally safe, it seems preferable to simply failing to do the deletes altogether in legacy autocommit mode.
For TwoPC mode, all the vtexplain test cases do work and I've included the output from a test run as part of this commit, but the output isn't stable across test runs since the values put into the twopc tracking tables include the timestamp. I still included the test output files in the PR since I found it informative to compare the output for the various modes (and to see exactly what TwoPC does under the covers).
Finally, I ended up reverting 1f3a930 since the sorting turned out to not actually be needed for stable test output and in fact it removed logical sequencing from the statements within a single time epoch which turns out to be important.