-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
release-23.1: randgen: disable generation of REGNAMESPACE type expressions #100771
Conversation
Casting an OID to REGNAMESPACE runs this SQL using the internal executor: ``` SELECT pg_namespace.oid, nspname FROM pg_catalog.pg_namespace WHERE oid = $1 ``` When the `GenerateConstrainedScans` rule is disabled, this returns no rows and so doesn't apply the cast. The same SQL, not run via an internal executor, but also with `GenerateConstrainedScans` disabled, behaves correctly. Disabling `GenerateConstrainedScans` all the time prevents the cluster from starting. The reason a full scan of pg_namespace doesn't find the OID is because it only checks for schemas in the current database: https://github.com/cockroachdb/cockroach/blob/7b341ffa678e4a22416e2274351fd56f415f5421/pkg/sql/virtual_schema.go#L602 https://github.com/cockroachdb/cockroach/blob/d10c3dd42c3dc40cad82792a30ae47fd2a663f43/pkg/sql/pg_catalog.go#L2099-L2106 https://github.com/cockroachdb/cockroach/blob/a7e9c4a68b81436d1f9382518d4267f74cbdac94/pkg/sql/information_schema.go#L2295-L2296 Whereas with a constrained scan, all descriptors are searched: https://github.com/cockroachdb/cockroach/blob/af6a72a622ae05f3733b5db637403b3eaa9455f1/pkg/sql/catalog/descs/descriptor.go#L168-L175 The correct result is from the constrained scan, because we currently allow cross-database references. Once #55791 is fixed, both results should match. The fix alternatives are: 1. disallow disabling of the `GenerateConstrainedScans` rule for internal SQL 2. turn off generation of REGNAMESPACE expressions in randgen to avoid hitting this problem in tests. The 2nd fix alternative is implemented to avoid losing any of the rule-disabling test coverage provided by the `testing_optimizer_disable_rule_probability` setting. Fixes #98322 Release note: None
b1bb979
to
367b8dc
Compare
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Don't forget to post to #release-backports and add a release justification.
backport approval request here |
TFTR! |
Backport 1/1 commits from #99168 on behalf of @msirek.
/cc @cockroachdb/release
Casting an OID to REGNAMESPACE runs this SQL using the internal executor:
When the
GenerateConstrainedScans
rule is disabled, this returns norows and so doesn't apply the cast. The same SQL, not run via an
internal executor, but also with
GenerateConstrainedScans
disabled,behaves correctly. Disabling
GenerateConstrainedScans
all the timeprevents the cluster from starting.
The reason a full scan of pg_namespace doesn't find the OID is because it
only checks for schemas in the current database:
cockroach/pkg/sql/virtual_schema.go
Line 602 in 7b341ff
cockroach/pkg/sql/pg_catalog.go
Lines 2099 to 2106 in d10c3dd
cockroach/pkg/sql/information_schema.go
Lines 2295 to 2296 in a7e9c4a
Whereas with a constrained scan, all descriptors are searched:
cockroach/pkg/sql/catalog/descs/descriptor.go
Lines 168 to 175 in af6a72a
The correct result is from the constrained scan, because we currently
allow cross-database references. Once #55791 is fixed, both results
should match.
The fix alternatives are:
GenerateConstrainedScans
rule for internal SQLThe 2nd fix alternative is implemented to avoid losing any of the
rule-disabling test coverage provided by the
testing_optimizer_disable_rule_probability
setting.Fixes #98322
Release justification: Test-only temporary fix to avoid test flakes until #55791 is fixed.