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

sql: fix CTAS when selecting from some internal virtual tables #105324

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

yuzefovich
Copy link
Member

This commit fixes an oversight where we forgot to set the SQL stats provider in some code paths (namely when NewInternalPlanner is called, one example is backfilling query into table that powers CREATE TABLE AS and CREATE MATERIALIZED VIEW AS features), and this is now fixed.

Fixes: #76710.

Release note (bug fix): Previously, CockroachDB would crash when evaluating CREATE TABLE .. AS or CREATE MATERIALIZED VIEW .. AS statements when AS clause selected data from
crdb_internal.cluster_statement_statistics or
crdb_internal.cluster_transaction_statistics virtual tables. The bug has been present since at least 22.1 and is now fixed.

@yuzefovich yuzefovich added backport-22.2.x backport-23.1.x Flags PRs that need to be backported to 23.1 labels Jun 22, 2023
@yuzefovich yuzefovich requested review from ecwall, a team and michae2 June 22, 2023 00:48
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this!
:lgtm:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ecwall and @michae2)

Copy link
Contributor

@j82w j82w left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this, you beat me to it. :lgtm:

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @ecwall and @michae2)

This commit fixes an oversight where we forgot to set the SQL stats
provider in some code paths (namely when `NewInternalPlanner` is called,
one example is backfilling query into table that powers CREATE TABLE AS
and CREATE MATERIALIZED VIEW AS features), and this is now fixed.

Release note (bug fix): Previously, CockroachDB would crash when
evaluating CREATE TABLE .. AS or CREATE MATERIALIZED VIEW .. AS
statements when AS clause selected data from
`crdb_internal.cluster_statement_statistics` or
`crdb_internal.cluster_transaction_statistics` virtual tables. The bug
has been present since at least 22.1 and is now fixed.
@yuzefovich yuzefovich requested a review from a team as a code owner June 22, 2023 01:35
@yuzefovich
Copy link
Member Author

As it turns out, I was the one who papered over this problem two years ago in 03ca31b 😅

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 22, 2023

Build failed:

@yuzefovich
Copy link
Member Author

Seems like unrelated flake.

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 22, 2023

Build failed:

@yuzefovich
Copy link
Member Author

Hm, perhaps the failure on acceptance/version-upgrade is somehow caused or exposed by this PR. I can't really understand what the failures are about. They look like

Error: ***UNEXPECTED ERROR; Received an unexpected execution error.: ERROR: at or near "null": syntax error: unimplemented: this syntax (SQLSTATE 0A000)
run_015321.116638924_n3_workload-run-schemac: 01:53:21 cluster.go:2301: > result: ./workload run schemachange {pgurl:1-4} --concurrency 2 --max-ops 10 --verbose 1 returned: COMMAND_PROBLEM: exit status 1
(1) ./workload run schemachange {pgurl:1-4} --concurrency 2 --max-ops 10 --verbose 1 returned
  | stderr:
  | I230622 01:53:21.285267 1 workload/cli/run.go:432  [-] 1  creating load generator...
  | I230622 01:53:21.373956 1 workload/cli/run.go:471  [-] 2  creating load generator... done (took 88.686941ms)
  | Error: ***UNEXPECTED ERROR; Received an unexpected execution error.: ERROR: at or near "null": syntax error: unimplemented: this syntax (SQLSTATE 0A000)
  |
  | stdout:
  | <... some data truncated by circular buffer; go to artifacts for details ...>
  | _LSN NULL, col6_8 FLOAT8 NOT NULL, UNIQUE (col6_8 DESC, \"col%c86_7\"), INDEX (\"col%c86_7\" DESC, col6_8 DESC), UNIQUE (\"col%c86_7\", col6_8 ASC), INDEX (col6_8 DESC, lower(CAST(\"col%c86_7\" AS STRING))), INDEX (\"col%c86_7\" DESC, col6_8), INDEX (col6_8 ASC) STORING (\"col%c86_7\"), FAMILY (col6_8), FAMILY (\"col%c86_7\"))"
  |   }
  |  ],
...
  | stderr:
  | I230622 01:56:19.920894 1 workload/cli/run.go:432  [-] 1  creating load generator...
  | I230622 01:56:20.007056 1 workload/cli/run.go:471  [-] 2  creating load generator... done (took 86.160591ms)
  | Error: ***UNEXPECTED ERROR; Received an unexpected execution error.: ERROR: at or near ",": syntax error: unimplemented: this syntax (SQLSTATE 0A000)
  |
  | stdout:
  | <... some data truncated by circular buffer; go to artifacts for details ...>
...

Let's try one more time, and if that doesn't work, I'll need help from SQL Foundations friends.

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 22, 2023

Build succeeded:

@blathers-crl
Copy link

blathers-crl bot commented Jun 22, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from cb097b5 to blathers/backport-release-22.2-105324: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


error setting reviewers, but backport branch blathers/backport-release-23.1-105324 is ready: POST https://api.github.com/repos/cockroachdb/cockroach/pulls/105325/requested_reviewers: 422 Reviews may only be requested from collaborators. One or more of the teams you specified is not a collaborator of the cockroachdb/cockroach repository. []

Backport to branch 23.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: create materalized view can cause panic
5 participants