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: implement idle_in_transaction_session_timeout #52938

Conversation

RichardJCai
Copy link
Contributor

Release note (sql change): Implement IdleInTransactionSessionTimeout
variable to allow terminating sessions that are idle in a transaction
past the provides threshold.

Set the variable by using SET idle_in_transaction_session_timeout = 'time'.

Sessions that are idle in OPEN, ABORTED and DONE(COMMITWAIT) transaction states
will be terminated if the user idles longer than the threshold time.

Fixes #5924

@RichardJCai RichardJCai requested a review from a team August 17, 2020 20:27
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RichardJCai RichardJCai requested review from solongordon and knz August 18, 2020 17:34
@RichardJCai RichardJCai force-pushed the idle_in_transaction_session_timeout_20200812 branch from 1c2fc2d to 0bb0dc7 Compare August 18, 2020 21:59
Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

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

I just tested this out manually and something seems off. I set the timeout variable and then ran BEGIN; followed immediately by SELECT 1. Then no matter how long I wait it doesn't seem like the session is canceled. Could you take a look?

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

Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

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

I take it back, I lost my session setting without realizing it.

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

Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

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

:lgtm: My only real complaint is the same as last time, which is that the tests take ~30 seconds to run. Any chance you could slim that down a bit without introducing flakiness?

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


pkg/sql/conn_executor_exec.go, line 153 at r1 (raw file):

		case stateOpen:
			// Only start timeout if the statement is executed in an
			// implicit transaction.

s/implicit/explicit/


pkg/sql/run_control_test.go, line 514 at r1 (raw file):

	time.Sleep(3 * time.Second)
	// The connection should still be alive.
	err = conn.PingContext(ctx)

Isn't this the same as what you test at the beginning of TestIdleInTransactionSessionTimeout?

@RichardJCai
Copy link
Contributor Author

RichardJCai commented Aug 20, 2020

:lgtm: My only real complaint is the same as last time, which is that the tests take ~30 seconds to run. Any chance you could slim that down a bit without introducing flakiness?

I'm going to try to decrease the time, can increase it if it introduces flakiness on CI.

Copy link
Contributor Author

@RichardJCai RichardJCai 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 @knz, @RichardJCai, and @solongordon)


pkg/sql/run_control_test.go, line 514 at r1 (raw file):

Previously, solongordon (Solon) wrote…

Isn't this the same as what you test at the beginning of TestIdleInTransactionSessionTimeout?

Yeah I think this is unnecessary

Release note (sql change): Implement IdleInTransactionSessionTimeout
variable to allow terminating sessions that are idle in a transaction
past the provides threshold.

Set the variable by using SET idle_in_transaction_session_timeout = 'time'.

Sessions that are idle in OPEN, ABORTED and DONE(COMMITWAIT) transaction states
will be terminated if the user idles longer than the threshold time.
@RichardJCai RichardJCai force-pushed the idle_in_transaction_session_timeout_20200812 branch from 0bb0dc7 to f5a1429 Compare August 20, 2020 20:09
@RichardJCai
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 20, 2020

Build succeeded:

@craig craig bot merged commit 904b7cb into cockroachdb:master Aug 20, 2020
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: implement idle_in_transaction_session_timeout
3 participants