Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt: add testing infrastructure to disable rules #30636

Merged
merged 1 commit into from
Sep 27, 2018

Conversation

rytaft
Copy link
Collaborator

@rytaft rytaft commented Sep 25, 2018

This commit adds testing infrastructure for randomly disabling
some transformation rules in the optimizer. The goal is to test that
alternate plans produced by the optimizer are logically equivalent.
It can be used to test that the logic tests still pass with some
rules randomly disabled as follows:

  > make test PKG=./pkg/sql/logictest/... TESTS='TestLogic/local-opt/.*' \
    TESTFLAGS='-disable-opt-rule-probability=0.1'

This test indicates that each transformation rule may be disabled with
10% probability. The value of -disable-opt-rule-probability can be any
value between 0.0 and 1.0.

Release note: None

This commit adds testing infrastructure for randomly disabling
some transformation rules in the optimizer. The goal is to test that
alternate plans produced by the optimizer are logically equivalent.
It can be used to test that the logic tests still pass with some
rules randomly disabled as follows:

  > make test PKG=./pkg/sql/logictest/... TESTS='TestLogic/local-opt/.*' \
    TESTFLAGS='-disable-opt-rule-probability=0.1'

This test indicates that each transformation rule may be disabled with
10% probability. The value of -disable-opt-rule-probability can be any
value between 0.0 and 1.0.

Release note: None
@rytaft rytaft requested a review from a team as a code owner September 25, 2018 14:51
@rytaft rytaft requested a review from a team September 25, 2018 14:51
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rytaft
Copy link
Collaborator Author

rytaft commented Sep 25, 2018

There are six rules which are "essential" because the tests panic if they are disabled. It's possible that this is an indication of bug(s). In particular disabling PruneJoinLeftCols and/or PruneJoinRightCols causes the error "same fingerprint cannot map to different groups". @andy-kimball may have a better idea about whether or not this is indicative of a bug.

Otherwise, the only tests that fail are those that fail with the error "could not decorrelate subquery". From the test runs I have done, it seems that the alternate plans are producing correct output.

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool! If you have some time, can you run it against the bigtest suite? Sample command line here: https://github.com/cockroachdb/cockroach/blob/master/build/teamcity-sqllogictest.sh#L18

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@rytaft
Copy link
Collaborator Author

rytaft commented Sep 25, 2018

👍 running now

@rytaft
Copy link
Collaborator Author

rytaft commented Sep 25, 2018

bigtest passed with -disable-opt-rule-probability=0.2

@justinj
Copy link
Contributor

justinj commented Sep 25, 2018

LGTM - I can't believe how little actual code this required, super cool

@rytaft
Copy link
Collaborator Author

rytaft commented Sep 27, 2018

TFTR!

bors r+

craig bot pushed a commit that referenced this pull request Sep 27, 2018
30636: opt: add testing infrastructure to disable rules r=rytaft a=rytaft

This commit adds testing infrastructure for randomly disabling
some transformation rules in the optimizer. The goal is to test that
alternate plans produced by the optimizer are logically equivalent.
It can be used to test that the logic tests still pass with some
rules randomly disabled as follows:
```
  > make test PKG=./pkg/sql/logictest/... TESTS='TestLogic/local-opt/.*' \
    TESTFLAGS='-disable-opt-rule-probability=0.1'
```
This test indicates that each transformation rule may be disabled with
10% probability. The value of -disable-opt-rule-probability can be any
value between 0.0 and 1.0.

Release note: None

30689: opt: show FKs in ddl output for test catalog r=justinj a=justinj

Also remove a TODO fixed by #30072.

Release note: None

30716: storage: proactively add to replicate queue on leader acquisition r=petermattis a=petermattis

Proactively add replicas to the replicate queue on Raft leader
acquisition. This is done in order to speed up removal of a replica when
the replica to be removed is the leaseholder. When that happens the
leaseholder transfers the lease to another replica and after the lease
is transferred Raft leadership is transferred. Prior to this change the
system then had to wait for the scanner on the new leaseholder node to
pick up the replica and complete the removal. Note that we wait for Raft
leadership to transfer because removal of a replica requires the
leaseholder to also be the Raft leader due to the checks in
`filterUnremovableReplicas` which ensure we're not removing a replica
that is critical for quorum.

Fixes #30695

Release note: None

Co-authored-by: Rebecca Taft <[email protected]>
Co-authored-by: Justin Jaffray <[email protected]>
Co-authored-by: Peter Mattis <[email protected]>
@craig
Copy link
Contributor

craig bot commented Sep 27, 2018

Build succeeded

@craig craig bot merged commit 97dc0f2 into cockroachdb:master Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants