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: add troubleshooting mode session variable #84452

Merged

Conversation

THardy98
Copy link

Resolves: #84429

This change introduces a troubleshooting_mode_enabled session
variable. When enabled, this session variable is intended to be used as
a way to avoid performing additional work on queries, particularly when
the cluster is experiencing issues/unavailability/failure. By default,
this session variable is disabled. Currently, this session variable is
only used to avoid collecting/emitting telemetry data.

Release note (sql change): Introduce new troubleshooting_mode_enabled
session variable, to avoid doing additional work on queries when
possible (i.e. collection telemetry data). By default, this session
variable is disabled.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@THardy98 THardy98 requested review from knz and a team July 14, 2022 20:48
@THardy98 THardy98 force-pushed the introduce_troubleshooting_session_variable branch 2 times, most recently from 8bc0d6e to e247f90 Compare July 15, 2022 19:34
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Since the value is already on/off you could name this troubleshooting_mode - the suffix _enabled is unnecessary in this case.

Also, it would be useful to hook this up to the behavior of cockroach sql --debug-sql-cli (see DebugMode in cli/clisqlclient/context.go)

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

@THardy98 THardy98 force-pushed the introduce_troubleshooting_session_variable branch from e247f90 to eab31a2 Compare July 18, 2022 20:20
@THardy98 THardy98 requested a review from a team July 18, 2022 20:20
@THardy98 THardy98 requested a review from a team as a code owner July 18, 2022 20:20
Copy link
Author

@THardy98 THardy98 left a comment

Choose a reason for hiding this comment

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

Renamed to troubleshooting_mode.

I've added a conditional to enable troubleshooting_mode if the DebugMode flag is set to true at configurePreShellDefaults, once we've parsed the CLI flags. Not sure if this is the best place to do this.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz)

@THardy98 THardy98 requested a review from knz July 19, 2022 13:30
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 9 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @THardy98)


pkg/cli/clisqlshell/sql.go line 2107 at r2 (raw file):

	}

	if c.sqlConnCtx.DebugMode {

you can put this logic inside a function alongside the others in clisqlcfg/context.go (maybeSetSafeUpdates etc) then call it from Run.

Then you can also add a test for this inside cli/interactive_tests/test_client_side_checking.tcl alongside the others that test the CLI flag.
For example, below the existing prompt expect:

send "show troubleshooting_mode\r"
eexpect "on"
eexpect "root@"

@THardy98 THardy98 force-pushed the introduce_troubleshooting_session_variable branch from eab31a2 to 1e2030a Compare July 19, 2022 14:36
Copy link
Author

@THardy98 THardy98 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 (waiting on @knz)


pkg/cli/clisqlshell/sql.go line 2107 at r2 (raw file):

Previously, knz (kena) wrote…

you can put this logic inside a function alongside the others in clisqlcfg/context.go (maybeSetSafeUpdates etc) then call it from Run.

Then you can also add a test for this inside cli/interactive_tests/test_client_side_checking.tcl alongside the others that test the CLI flag.
For example, below the existing prompt expect:

send "show troubleshooting_mode\r"
eexpect "on"
eexpect "root@"

moved logic to maybeSetTroubleshootingMode, called from Run

added the suggested test to cli/interactive_tests/test_client_side_checking.tcl

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @THardy98)


pkg/cli/clisqlcfg/context.go line 259 at r3 (raw file):

func (c *Context) maybeSetTroubleshootingMode(conn clisqlclient.Conn) error {
	// If we are in debug mode, enable "troubleshooting mode".
	if c.ConnCtx.DebugMode {

easier on the eye:

if !cond { return nil }
return dothething()

pkg/cli/interactive_tests/test_client_side_checking.tcl line 100 at r3 (raw file):

# Check that troubleshooting mode is enabled in debug mode.
send "show troubleshooting_mode\r"

this is not the correct place - the test has exited the sql client already above.

@THardy98 THardy98 force-pushed the introduce_troubleshooting_session_variable branch from 1e2030a to ebbda5b Compare July 19, 2022 15:41
Copy link
Author

@THardy98 THardy98 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 (waiting on @knz)


pkg/cli/clisqlcfg/context.go line 259 at r3 (raw file):

Previously, knz (kena) wrote…

easier on the eye:

if !cond { return nil }
return dothething()

Done.


pkg/cli/interactive_tests/test_client_side_checking.tcl line 100 at r3 (raw file):

Previously, knz (kena) wrote…

this is not the correct place - the test has exited the sql client already above.

Oops, moved earlier.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

:lgtm: with nit

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


pkg/cli/interactive_tests/test_client_side_checking.tcl line 91 at r4 (raw file):

# Check that troubleshooting mode is enabled in debug mode.
send "show troubleshooting_mode\r"

you still need to wait for the prompt before sending the command (eexpect "root@" just before)

@THardy98 THardy98 force-pushed the introduce_troubleshooting_session_variable branch from ebbda5b to 0326230 Compare July 19, 2022 15:56
Copy link
Author

@THardy98 THardy98 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) (waiting on @knz)


pkg/cli/interactive_tests/test_client_side_checking.tcl line 91 at r4 (raw file):

Previously, knz (kena) wrote…

you still need to wait for the prompt before sending the command (eexpect "root@" just before)

Done.

@THardy98
Copy link
Author

TYFR :)

Resolves: cockroachdb#84429

This change introduces a `troubleshooting_mode_enabled` session
variable. When enabled, this session variable is intended to be used as
a way to avoid performing additional work on queries, particularly when
the cluster is experiencing issues/unavailability/failure. By default,
this session variable is disabled.  Currently, this session variable is
only used to avoid collecting/emitting telemetry data.

Release note (sql change): Introduce new `troubleshooting_mode_enabled`
session variable, to avoid doing additional work on queries when
possible (i.e. collection telemetry data). By default, this session
variable is disabled.
@THardy98 THardy98 force-pushed the introduce_troubleshooting_session_variable branch from 0326230 to fd39cd3 Compare July 20, 2022 19:04
@THardy98
Copy link
Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 21, 2022

Build succeeded:

@THardy98
Copy link
Author

blathers backport 22.1 21.2

@blathers-crl
Copy link

blathers-crl bot commented Jul 21, 2022

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 fd39cd3 to blathers/backport-release-22.1-84452: 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.1 failed. See errors above.


error creating merge commit from fd39cd3 to blathers/backport-release-21.2-84452: 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 21.2 failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

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.

Introduce "troubleshooting" session variable to conditionally gather more information
4 participants