-
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
sql: v21.2.6: expected *DArray, found tree.dNull when folding a comparison #77745
Comments
Hi Cockroach team, We upgraded to 21.2.6 and have started to observe this error. What's the mitigation here? What are we exposed to with this issue (i.e what's the impact to the cluster?) |
From the stack trace we can tell that this is caused by a query using the It would help to have the query, if we can find it. None of these cause the error, so it's not something obvious: SELECT NULL <@ NULL;
SELECT NULL <@ ARRAY[]:::int[];
SELECT NULL <@ ARRAY[1];
SELECT (NULL <@ ARRAY[1]) <@ ARRAY[2];
SELECT a <@ ARRAY[1,2,3] FROM (VALUES (NULL)) AS v(a); |
The other two sentry reports show an |
@michae2 for us it happens when inserting null into a nullable ARRAY column. Inserting an empty array doesn't exhibit the behaviour. Before the upgrade, null into a nullable ARRAY column worked without an issue. |
Aha, here's one way to hit it: PREPARE s AS SELECT $1:::INT[] <@ $2:::INT[];
EXECUTE s (NULL, ARRAY[1]);
|
@mqdeandrade I see, thank you, that helps. Do you happen to have the |
Thanks to @moogzy we saw that the table does indeed have a check constraint using CREATE TABLE t (a STRING[] NULL, CHECK (a <@ ARRAY['x']));
INSERT INTO t VALUES (NULL); Demonstration:
|
Interesting, this only reproduces for the CREATE TABLE arraycontainedby (a STRING[], CHECK (a <@ ARRAY['x']));
CREATE TABLE arraycontainedbyrev (a STRING[], CHECK (ARRAY['x'] <@ a));
CREATE TABLE arraycontainedbyboth (a STRING[], CHECK (a <@ a));
CREATE TABLE arraycontains (a STRING[], CHECK (a @> ARRAY['x']));
CREATE TABLE arraycontainsrev (a STRING[], CHECK (ARRAY['x'] @> a));
CREATE TABLE arrayoverlaps (a STRING[], CHECK (a && ARRAY['x']));
CREATE TABLE jsoncontainedby (j JSONB, CHECK (j <@ '["x"]'::JSONB));
CREATE TABLE jsoncontainedbyrev (j JSONB, CHECK ('["x"]'::JSONB <@ j));
CREATE TABLE jsoncontainedbyboth (j JSONB, CHECK (j <@ j));
CREATE TABLE jsoncontains (j JSONB, CHECK (j @> '["x"]'::JSONB));
CREATE TABLE jsoncontainsrev (j JSONB, CHECK ('["x"]'::JSONB @> j));
CREATE TABLE jsonexists (j JSONB, CHECK (j ? 'x'));
CREATE TABLE intgt (i INT, CHECK (i > 0));
INSERT INTO arraycontainedby VALUES (NULL); -- error
INSERT INTO arraycontainedbyrev VALUES (NULL);
INSERT INTO arraycontainedbyboth VALUES (NULL);
INSERT INTO arraycontains VALUES (NULL);
INSERT INTO arraycontainsrev VALUES (NULL);
INSERT INTO arrayoverlaps VALUES (NULL);
INSERT INTO jsoncontainedby VALUES (NULL); -- error
INSERT INTO jsoncontainedbyrev VALUES (NULL);
INSERT INTO jsoncontainedbyboth VALUES (NULL);
INSERT INTO jsoncontains VALUES (NULL);
INSERT INTO jsoncontainsrev VALUES (NULL);
INSERT INTO jsonexists VALUES (NULL);
INSERT INTO intgt VALUES (NULL); This suggests a simple workaround is to change |
Here's an even simpler repro: SELECT NULL::STRING[] <@ ARRAY['x']; (Apparently type checking has its own constant folding which was hiding this failure to constant fold in the optimizer.) |
77875: sql: use IndexFetchSpec for inverted joiner r=RaduBerinde a=RaduBerinde #### rowexec: address TODO in inverted joiner This commit addresses a TODO in the inverted joiner. We now reuse a buffer for encoding the prefix key. In the general case we still need to make a copy since we are storing multiple prefix keys; but now we try to reuse the last copy if the prefix is the same. We also remove the temporary use of `indexRow` which is confusing here (it wasn't obvious at first but this code has nothing to do with index rows and is just using `indexRow` as a temporary buffer). Release note: None #### geoindex: minor cleanup around Config This change changes `IsEmptyConfig`, `IsGeographyConfig`, `IsGeometryConfig` to methods on the `geoindex.Config` type. We also switch to passing configs by value which is cleaner and avoids some allocations. Release note: None #### sql: use IndexFetchSpec for inverted joiner This commit reworks the InvertedJoiner to use an IndexFetchSpec instead of table and index descriptors. The "internal schema" now matches the fetched columns (leading to simplifications in both planning and execution code). Release note: None 77878: kvstreamer: re-enable streamer by default r=yuzefovich a=yuzefovich Release note: None 77968: sql: keep experimental_enable_hash_sharded_indexes var as noop r=chengxiong-ruan a=chengxiong-ruan Fixes #77954 Release justification: needed for session var backward compatibility. Release note (sql change): experimental_enable_hash_sharded_indexes used to be set to enable the hash sharded index feature. since we now enable the feature by default, user don't need to set this var anymore. But still keeping it as noop for backward compatibility. 77995: opt: add ContainedBy operator (<@) to FoldNullComparisonLeft norm rule r=msirek,mgartner a=michae2 Fixes: #77745 When we originally made the ContainedBy operator (<`@)` distinct from the Contains operator (`@>)` we forgot to add ContainedBy to the FoldNullComparisonLeft normalization rule. It was only added to the FoldNullComparisonRight rule. Correct this. Release note (bug fix): fix an optimizer bug that prevented expressions of the form (NULL::STRING[] <@ ARRAY['x']) from being folded to NULL. 78013: roachtest: fix handling of test panics r=erikgrinaker a=tbg - roachtest: fix handling of test panics - roachtest: gracefully fail in sst-corruption test 78023: roachprod: update thrift artifact url for use with charybdefs r=tbg a=nicktrav The version of Thrift used in tests that use `charybdefs` has disappeared from the Apache artifacts repository that is used currently, which causes any roachtest that depends on `charybdefs` to fail due to not being able to fetch the artifact it needs. Update the artifact URL to pull from the Apache archive instead. Touches #78006,#78007,#78008,#78010,#78015,#78016. Release note: None. Co-authored-by: Radu Berinde <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: Chengxiong Ruan <[email protected]> Co-authored-by: Michael Erickson <[email protected]> Co-authored-by: Tobias Grieger <[email protected]> Co-authored-by: Nick Travers <[email protected]>
Fixes: #77745 When we originally made the ContainedBy operator (<@) distinct from the Contains operator (@>) we forgot to add ContainedBy to the FoldNullComparisonLeft normalization rule. It was only added to the FoldNullComparisonRight rule. Correct this. Release note (bug fix): fix an optimizer bug that prevented expressions of the form (NULL::STRING[] <@ ARRAY['x']) from being folded to NULL.
Fixes: #77745 When we originally made the ContainedBy operator (<@) distinct from the Contains operator (@>) we forgot to add ContainedBy to the FoldNullComparisonLeft normalization rule. It was only added to the FoldNullComparisonRight rule. Correct this. Release note (bug fix): fix an optimizer bug that prevented expressions of the form (NULL::STRING[] <@ ARRAY['x']) from being folded to NULL. Release justification: high priority bug fix.
Fixes: #77745 When we originally made the ContainedBy operator (<@) distinct from the Contains operator (@>) we forgot to add ContainedBy to the FoldNullComparisonLeft normalization rule. It was only added to the FoldNullComparisonRight rule. Correct this. Release note (bug fix): fix an optimizer bug that prevented expressions of the form (NULL::STRING[] <@ ARRAY['x']) from being folded to NULL. Release justification: high priority bug fix.
Fixes: #77745 When we originally made the ContainedBy operator (<@) distinct from the Contains operator (@>) we forgot to add ContainedBy to the FoldNullComparisonLeft normalization rule. It was only added to the FoldNullComparisonRight rule. Correct this. Release note (bug fix): fix an optimizer bug that prevented expressions of the form (NULL::STRING[] <@ ARRAY['x']) from being folded to NULL. This bug was introduced in v21.2.0. Release justification: high priority bug fix.
Fixes: #77745 When we originally made the ContainedBy operator (<@) distinct from the Contains operator (@>) we forgot to add ContainedBy to the FoldNullComparisonLeft normalization rule. It was only added to the FoldNullComparisonRight rule. Correct this. Release note (bug fix): fix an optimizer bug that prevented expressions of the form (NULL::STRING[] <@ ARRAY['x']) from being folded to NULL. This bug was introduced in v21.2.0. Release justification: high priority bug fix.
This issue was autofiled by Sentry. It represents a crash or reported error on a live cluster with telemetry enabled.
Sentry link: https://sentry.io/organizations/cockroach-labs/issues/3097249090/?referrer=webhooks_plugin
Panic message:
Stacktrace (expand for inline code snippets):
cockroach/pkg/sql/sem/tree/datum.go
Lines 3945 to 3947 in c7cfac5
cockroach/pkg/sql/sem/tree/eval.go
Lines 2566 to 2568 in c7cfac5
cockroach/pkg/sql/opt/norm/fold_constants_funcs.go
Lines 438 to 440 in c7cfac5
https://github.com/cockroachdb/cockroach/blob/c7cfac57476f06e3154b2fc38e77982a8bbc64c2/pkg/sql/opt/norm/factory.og.go#L16765-L16767 in pkg/sql/opt/norm.(*Factory).ConstructContainedBy
https://github.com/cockroachdb/cockroach/blob/c7cfac57476f06e3154b2fc38e77982a8bbc64c2/pkg/sql/opt/norm/factory.og.go#L22243-L22245 in pkg/sql/opt/norm.(*Factory).Replace
cockroach/pkg/sql/opt/norm/inline_funcs.go
Lines 92 to 94 in c7cfac5
cockroach/pkg/sql/opt/norm/inline_funcs.go
Lines 94 to 96 in c7cfac5
cockroach/pkg/sql/opt/norm/inline_funcs.go
Lines 54 to 56 in c7cfac5
https://github.com/cockroachdb/cockroach/blob/c7cfac57476f06e3154b2fc38e77982a8bbc64c2/pkg/sql/opt/norm/factory.og.go#L1348-L1350 in pkg/sql/opt/norm.(*Factory).ConstructProject
cockroach/pkg/sql/opt/optbuilder/project.go
Lines 60 to 62 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/project.go
Lines 35 to 37 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/mutation_builder.go
Lines 907 to 909 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/insert.go
Lines 668 to 670 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/insert.go
Lines 287 to 289 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/builder.go
Lines 292 to 294 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/with.go
Lines 110 to 112 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/builder.go
Lines 291 to 293 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/builder.go
Lines 240 to 242 in c7cfac5
cockroach/pkg/sql/opt/optbuilder/builder.go
Lines 214 to 216 in c7cfac5
cockroach/pkg/sql/plan_opt.go
Lines 379 to 381 in c7cfac5
cockroach/pkg/sql/plan_opt.go
Lines 122 to 124 in c7cfac5
cockroach/pkg/sql/conn_executor_prepare.go
Lines 286 to 288 in c7cfac5
cockroach/pkg/sql/conn_executor_prepare.go
Lines 219 to 221 in c7cfac5
cockroach/pkg/sql/conn_executor_prepare.go
Lines 225 to 227 in c7cfac5
cockroach/pkg/sql/conn_executor_prepare.go
Lines 110 to 112 in c7cfac5
cockroach/pkg/sql/conn_executor_prepare.go
Lines 52 to 54 in c7cfac5
cockroach/pkg/sql/conn_executor.go
Lines 1796 to 1798 in c7cfac5
cockroach/pkg/sql/conn_executor.go
Lines 1628 to 1630 in c7cfac5
cockroach/pkg/sql/conn_executor.go
Lines 667 to 669 in c7cfac5
cockroach/pkg/sql/pgwire/conn.go
Lines 647 to 649 in c7cfac5
/usr/local/go/src/runtime/asm_amd64.s#L1370-L1372 in runtime.goexit
v21.2.6
Jira issue: CRDB-13748
gz#11753
The text was updated successfully, but these errors were encountered: