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: expose an ability to request redacted stmt bundles #123859

Merged
merged 1 commit into from
May 15, 2024

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented May 9, 2024

This commit extends the stmt bundle collection infrastructure to support requesting redacted stmt bundles. Previously, this was only possible via an explicit EXPLAIN ANALYZE (DEBUG, REDACT) stmt, but this commit adds the support via overloads to crdb_internal.request_statement_bundle builtin as well as the server API. This paves the way for requesting the redacted bundles via the DB Console, but it'll be done separately.

To support this we need to add another boolean column to system.statement_diagnostics_requests table to indicate whether a request is for the redacted bundle or not. This requires adding a migration in which we populate the existing rows with all false values.

In order to reduce the amount of code churn and simplify this change, this commit repurposes some of the existing code that we introduced the last time we added a migration for plan-gist matching in stmt bundles. In other words, this commit simultenously removes some stale code and handles the new column.

Epic: CRDB-37839

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich yuzefovich force-pushed the bundle-redacted branch 4 times, most recently from d5a618b to ddec74d Compare May 15, 2024 01:05
@yuzefovich yuzefovich marked this pull request as ready for review May 15, 2024 01:44
@yuzefovich yuzefovich requested review from a team as code owners May 15, 2024 01:44
@yuzefovich yuzefovich requested review from nkodali, a team and DrewKimball and removed request for a team and nkodali May 15, 2024 01:44
Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice, thanks for tackling this!

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


pkg/sql/instrumentation.go line 635 at r1 (raw file):

				// explicitly. We also need to set RedactValues when this bundle
				// is being collected for the request that asked for redaction.
				ih.explainFlags.RedactValues = true

[nit] Should we do this in Setup and setupWithPlanGist when ih.diagRequest is first set?

This commit extends the stmt bundle collection infrastructure to support
requesting redacted stmt bundles. Previously, this was only possible via
an explicit `EXPLAIN ANALYZE (DEBUG, REDACT)` stmt, but this commit adds
the support via overloads to `crdb_internal.request_statement_bundle`
builtin as well as the server API. This paves the way for requesting the
redacted bundles via the DB Console, but it'll be done separately.

To support this we need to add another boolean column to
`system.statement_diagnostics_requests` table to indicate whether
a request is for the redacted bundle or not. This requires adding
a migration in which we populate the existing rows with all `false`
values.

In order to reduce the amount of code churn and simplify this change,
this commit repurposes some of the existing code that we introduced the
last time we added a migration for plan-gist matching in stmt bundles.
In other words, this commit simultenously removes some stale code and
handles the new column.

Release note: None
Copy link
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r+

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


pkg/sql/instrumentation.go line 635 at r1 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

[nit] Should we do this in Setup and setupWithPlanGist when ih.diagRequest is first set?

Done.

@yuzefovich
Copy link
Member Author

bors r+

@craig craig bot merged commit 046440d into cockroachdb:master May 15, 2024
22 checks passed
@yuzefovich yuzefovich deleted the bundle-redacted branch May 15, 2024 20:11
Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Nicely done!

Reviewed 26 of 31 files at r1, 5 of 5 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/upgrade/upgrades/redacted_stmt_diagnostics_requests.go line 31 at r2 (raw file):

	createCompletedIdx = `
CREATE INDEX completed_idx ON system.statement_diagnostics_requests (completed, ID)

nit: Should this be named with a _v3 suffix for future migrations? Or did you consider that a bad pattern?


pkg/sql/logictest/testdata/logic_test/gen_test_objects line 210 at r2 (raw file):

protected_ts_meta      "vers
ion"               bigint
"ran gelog"            "%rangeID"               bigint

Any idea what happened here?

Copy link
Member Author

@yuzefovich yuzefovich 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! 0 of 0 LGTMs obtained (and 1 stale)


pkg/upgrade/upgrades/redacted_stmt_diagnostics_requests.go line 31 at r2 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

nit: Should this be named with a _v3 suffix for future migrations? Or did you consider that a bad pattern?

I thought it would be cleaner to just have completed_idx. We've modified this index a few times in the past, and I think every time it was v -> v2 or v2 -> v transition. At this point it would have been probably v6 or something if we simply incremented it every time. I don't really have an opinion here, just v seems cleanest to me. It don't think I've seen any guidelines for migrations in general either, perhaps it might be worth writing up a quick style guide?


pkg/sql/logictest/testdata/logic_test/gen_test_objects line 210 at r2 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

Any idea what happened here?

IIUC planner.GenerateTestObjects (which powers crdb_internal.generate_test_objects builtin) uses system descriptors, and since we changed the descriptor for a system table, the output of the builtin also changed.

Copy link
Collaborator

@mgartner mgartner 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! 0 of 0 LGTMs obtained (and 1 stale)


pkg/upgrade/upgrades/redacted_stmt_diagnostics_requests.go line 31 at r2 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

I thought it would be cleaner to just have completed_idx. We've modified this index a few times in the past, and I think every time it was v -> v2 or v2 -> v transition. At this point it would have been probably v6 or something if we simply incremented it every time. I don't really have an opinion here, just v seems cleanest to me. It don't think I've seen any guidelines for migrations in general either, perhaps it might be worth writing up a quick style guide?

Eh, probably not worth a style guide. Just a drive-by comment. I don't have a strong opinion either.


pkg/sql/logictest/testdata/logic_test/gen_test_objects line 210 at r2 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

IIUC planner.GenerateTestObjects (which powers crdb_internal.generate_test_objects builtin) uses system descriptors, and since we changed the descriptor for a system table, the output of the builtin also changed.

Ahh thanks for the info!

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