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

release-22.1: sql: execute batch statements in an implicit transaction #77865

Merged
merged 3 commits into from
Mar 16, 2022

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Mar 15, 2022

Backport 3/3 commits from #76834.

/cc @cockroachdb/release


fixes #44803
relates to #76490

Release justification: high value bug fix to existing functionality

*: prepare tests for batch stmt txn change

This commit will make the next one easier to review.

sql: execute batch statements in an implicit transaction

Release note (bug fix): Previously statements that arrived in a batch
during the simple query protocol would all execute in their own implicit
transactions. Now, we match the Postgres wire protocol, so all these
statements share the same implicit transaction. If a BEGIN is included
in a statement batch, then the existing implicit transaction is
upgraded to an explicit transaction.

sql: add session var for old implicit txn behavior

Release note (sql change): The enable_implicit_transaction_for_batch_statements
session variable was added. It defaults to true. When it is true,
multiple statements in a single query (a.k.a. a "batch statement") will
all be run in the same implicit transaction, which matches the Postgres
wire protocol. This setting is provided for users who want to preserve
the behavior of CockroachDB versions v21.2 and earlier.

rafiss added 3 commits March 15, 2022 18:28
This commit will make the next one easier to review.

Release justification: test only change

Release note: None
Release justification: high value bug fix to existing functionality.

Release note (bug fix): Previously statements that arrived in a batch
during the simple query protocol would all execute in their own implicit
transactions. Now, we match the Postgres wire protocol, so all these
statements share the same implicit transaction. If a BEGIN is included
in a statement batch, then the existing implicit transaction is
upgraded to an explicit transaction.
Release justification: low risk new setting.

Release note (sql change): The enable_implicit_transaction_for_batch_statements
session variable was added. It defaults to true. When it is true,
multiple statements in a single query (a.k.a. a "batch statement") will
all be run in the same implicit transaction, which matches the Postgres
wire protocol. This setting is provided for users who want to preserve
the behavior of CockroachDB versions v21.2 and earlier.
@rafiss rafiss requested a review from otan March 15, 2022 22:28
@rafiss rafiss requested review from a team as code owners March 15, 2022 22:28
@rafiss rafiss requested review from a team March 15, 2022 22:28
@rafiss rafiss requested review from a team as code owners March 15, 2022 22:28
@rafiss rafiss requested a review from a team March 15, 2022 22:28
@rafiss rafiss requested review from a team as code owners March 15, 2022 22:28
@rafiss rafiss requested review from miretskiy and adityamaru and removed request for a team March 15, 2022 22:28
@blathers-crl
Copy link

blathers-crl bot commented Mar 15, 2022

Thanks for opening a backport.

Please check the backport criteria before merging:

  • Patches should only be created for serious issues or test-only changes.
  • Patches should not break backwards-compatibility.
  • Patches should change as little code as possible.
  • Patches should not change on-disk formats or node communication protocols.
  • Patches should not add new functionality.
  • Patches must not add, edit, or otherwise modify cluster versions; or add version gates.
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
  • There is a high priority need for the functionality that cannot wait until the next release and is difficult to address in another way.
  • The new functionality is additive-only and only runs for clusters which have specifically “opted in” to it (e.g. by a cluster setting).
  • New code is protected by a conditional check that is trivial to verify and ensures that it only runs for opt-in clusters.
  • The PM and TL on the team that owns the changed code have signed off that the change obeys the above rules.

Add a brief release justification to the body of your PR to justify this backport.

Some other things to consider:

  • What did we do to ensure that a user that doesn’t know & care about this backport, has no idea that it happened?
  • Will this work in a cluster of mixed patch versions? Did we test that?
  • If a user upgrades a patch version, uses this feature, and then downgrades, what happens?

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner
Copy link
Contributor

Have we considered setting the default value on the cluster setting to false for 22.1? This seems scary and we didn't give a release's worth of notice of this behavior change. @vy-ton ? Now that we have it, anybody hitting it can just change the default, so we'll have resolved the blocker for anybody. I worry that this is going to hurt more than one customer and we won't get to point to a bunch of release notes saying it was coming.

This was referenced Mar 16, 2022
@rafiss
Copy link
Collaborator Author

rafiss commented Mar 16, 2022

I viewed it as a bug fix, so didn't think that was necessary. It was discussed here: #76834 (comment) I'm still in favor of keeping the fixed behavior on by default, but also happy to hear more perspectives and discuss.

won't get to point to a bunch of release notes saying it was coming.

I didn't follow this point though. We don't put up release notes for features that are coming at some point in the future. The release notes only communicate was in the binary that is being documented. Also, now this bug fix will be documented in the beta.1 release, so we can point people to that and give them a heads up.

If the point is about a release's worth of testing, then I see what you mean. But I think all the testing that we'll get on release-22.1 during stability period before the GA release is sufficient.

I guess ultimately it comes back to the "bug fix or breaking change" debate. I view this one as a bug fix since it's something at the pgwire protocol level, and the general sentiment of our docs says that we implement the pgwire protocol as exactly as we can.

@ajwerner
Copy link
Contributor

Just because it's a "bug fix" doesn't mean it is not a breaking change. We've had many a bug fix in the past that broke stuff and customers were unhappy. What's worse about this one, in my opinion, is that it's not a bug in the sense of what we documented or in the sense that it caused corruption or invalid results. It's an incompatibility and behavior difference with postgres, so we call it a bug. I think I'd frame this more as a compatibility improvement that comes with a breaking change which we should give our users notice about.

@ajwerner
Copy link
Contributor

It's also fortunate that this isn't a stateful property: we don't need a migration, it's just a switch. Anybody who wants this behavior change and has been waiting for it will be excited to see they can have it. Folks who know nothing about this will be actively upset when their stuff which currently works breaks. They will be right to complain.

@ajwerner
Copy link
Contributor

Let's get @vy-ton to explicitly sign off. This feels like exactly the sort of thing we should be more cautious about because it costs us nearly nothing to be cautious.

@rafiss rafiss deleted the backport22.1-76834 branch March 16, 2022 20:04
@rafiss
Copy link
Collaborator Author

rafiss commented Mar 17, 2022

changed to false by default in #77973

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