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 crash when explaining a constrained virtual table scan #58208

Merged
merged 1 commit into from
Dec 23, 2020

Conversation

RaduBerinde
Copy link
Member

When emitting EXPLAIN (VERBOSE) output, we use a callback to
generate and format the physical spans; this callback currently
crashes for virtual tables.

Note that this code path is used when collecting statement
diagnostics, which can lead to a severe situation.

The fix is to always show the logical spans and use the callback only
for physical tables.

In addition, we add logic to catch panics inside emitExplain;
unfortunately, it would not have helped here because the panic object
was a bare string (and not an assertion error).

Fixes #58193.

Release note (bug fix): fixed a "column family 0 not found" crash
caused by explaining or gathering statement diagnostics on certain
queries involving virtual tables.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks for fixing!

Reviewed 5 of 5 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jordanlewis and @RaduBerinde)


pkg/sql/explain_plan.go, line 171 at r1 (raw file):

	spanFormatFn := func(table cat.Table, index cat.Index, scanParams exec.ScanParams) string {
		if table.IsVirtualTable() {
			return "<internal error>"

Feels like this message could have a bit more detail -- maybe mention virtual tables?

When emitting `EXPLAIN (VERBOSE)` output, we use a callback to
generate and format the physical spans; this callback currently
crashes for virtual tables.

Note that this code path is used when collecting statement
diagnostics, which can lead to a severe situation.

The fix is to always show the logical spans and use the callback only
for physical tables.

In addition, we add logic to catch panics inside emitExplain;
unfortunately, it would not have helped here because the panic object
was a bare string (and not an assertion error).

Fixes cockroachdb#58193.

Release note (bug fix): fixed a "column family 0 not found" crash
caused by explaining or gathering statement diagnostics on certain
queries involving virtual tables.
Copy link
Member Author

@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.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jordanlewis and @rytaft)


pkg/sql/explain_plan.go, line 171 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

Feels like this message could have a bit more detail -- maybe mention virtual tables?

Done.

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @jordanlewis)

Copy link
Member Author

@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.

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @jordanlewis)

@craig
Copy link
Contributor

craig bot commented Dec 23, 2020

Build succeeded:

@craig craig bot merged commit ba6feb8 into cockroachdb:master Dec 23, 2020
@RaduBerinde RaduBerinde deleted the explain-spans-crash branch December 24, 2020 01:50
@rafiss rafiss added this to the 20.2 milestone Apr 22, 2021
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.

sql: explain crash when showing spans for virtual table
4 participants