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 server.max_open_transactions_per_gateway cluster setting #118781

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Feb 5, 2024

informs #110272
Release note (sql change): Added the
server.max_open_transactions_per_gateway cluster setting. When set to a non-negative value, then non-admin users cannot execute a query if the number of transactions open on the current gateway node is already at the configured limit.

@rafiss rafiss added backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. labels Feb 5, 2024
@rafiss rafiss requested review from andrewbaptist and a team February 5, 2024 21:03
Copy link

blathers-crl bot commented Feb 5, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

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

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss rafiss force-pushed the max-active-per-gateway branch from d68dd54 to 201bab3 Compare February 5, 2024 21:12
@rafiss rafiss requested a review from sumeerbhola February 6, 2024 18:53
Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

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

I don't have enough context to review this.

Is there any recommendation for how cluster operators can set this prior to an outage? Should they be looking at the max value of sql.txns.open over a long time duration and use that to guide what they set this to?

Can they use this during an outage -- will it effect transactions that are already open? If not, is the hope that enough transactions are completing that it will soon have an effect?

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

Copy link
Collaborator

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

:lgtm:

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


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

	ih := &p.instrumentation

	if maxOpen := maxOpenTransactions.Get(&ex.server.cfg.Settings.SV); maxOpen > 0 {

Unrelated and more of a comment, but I can imagine queuing behaviour might be preferred in certain cases.

@rafiss
Copy link
Collaborator Author

rafiss commented Feb 7, 2024

Is there any recommendation for how cluster operators can set this prior to an outage? Should they be looking at the max value of sql.txns.open over a long time duration and use that to guide what they set this to?

I think looking at sql.txns.open over a long time is a good heuristic for deciding how to set this proactively.

Another heuristic is our guidance that says that the number of actively running transactions should not greatly exceed (number of cores) * 4.

Can they use this during an outage -- will it effect transactions that are already open?

Yes. The check and error would occur as soon as the next statement in a transaction begins executing, after this cluster setting is applied. I can add a test for that.

Release note (sql change): Added the
server.max_open_transactions_per_gateway cluster setting. When set to a
non-negative value, then non-admin users cannot execute a query if the
number of transactions open on the current gateway node is already at
the configured limit.
@rafiss rafiss force-pushed the max-active-per-gateway branch from 201bab3 to a07fb8d Compare February 7, 2024 21:40
@rafiss
Copy link
Collaborator Author

rafiss commented Feb 8, 2024

tftr!

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 8, 2024

Build succeeded:

@craig craig bot merged commit 7074888 into cockroachdb:master Feb 8, 2024
8 of 9 checks passed
Copy link

blathers-crl bot commented Feb 8, 2024

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 a07fb8d to blathers/backport-release-23.1-118781: 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 23.1.x failed. See errors above.


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

@arulajmani
Copy link
Collaborator

@rafiss friendly ping to manually backport this to 23.1 -- the blathers backport failed. We had an escalation (https://github.com/cockroachlabs/support/issues/2812) where this could have been useful.

@cockroachdb cockroachdb deleted a comment from blathers-crl bot Feb 8, 2024
@rafiss rafiss deleted the max-active-per-gateway branch February 8, 2024 17:50
andrewbaptist added a commit to andrewbaptist/cockroach that referenced this pull request Apr 10, 2024
Previously this test was created but wasn't run since it would always
fail. The test still doesn't pass in the default configuration, however
after the addition of cockroachdb#118781, at least it is possible to configure a
cluster to pass.

Informs: cockroachdb#110272
Informs: cockroachdb#89142

Release note: None
craig bot pushed a commit that referenced this pull request Apr 19, 2024
121833: roachtest: update tpcc overload r=rafiss a=andrewbaptist

Previously this test was created but wasn't run since it would always fail. The test still doesn't pass in the default configuration, however after the addition of #118781, at least it is possible to configure a cluster to pass.

Informs: #110272
Informs: #89142

Release note: None

Co-authored-by: Andrew Baptist <[email protected]>
@@ -548,6 +548,25 @@ func (ex *connExecutor) execStmtInOpenState(
p.noticeSender = res
ih := &p.instrumentation

if maxOpen := maxOpenTransactions.Get(&ex.server.cfg.Settings.SV); maxOpen > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the behavior when server.max_open_transactions_per_gateway is zero? Seems like it's still unlimited?

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 backport-23.2.x Flags PRs that need to be backported to 23.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants