-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: remove the artifact of canceling the txn-scoped context #84628
sql: remove the artifact of canceling the txn-scoped context #84628
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)
pkg/sql/exec_util.go
line 2294 at r1 (raw file):
// context cancellation). To go around that, we pass the responsibility // of finishing the span to the cancellation function. cancelTxnCtx := st.ex.state.cancel
I think finishing sp
here was better. I think a better fix would be to call st.ex.state.cancel
here, and then overwrite it.
But, actually, I don't understand why ex.state.cancel
exists - why do we have a transaction-level cancelation? There's logically no such thing as canceling a transaction, is there? I think the only use of state.cancel
is CANCEL QUERY
, which could do with a statement-level cancel func. A statement-level func I think could be scoped to execStmtInOpenState
. Then we wouldn't need this more troublesome and unclearly scoped transaction-level cancelation.
The transaction-level cancelation might have been a left-over from an ancient time when
a) we had parallel statements (returning nothing
)
b) the TxnCoordSender's heartbeat loop was using a transaction-scoped SQL ctx.
Neither of these are true any more.
WDYT?
This commit removes an old artifact of having a txn-scoped context cancellation that is performed when finishing the txn. As Andrei points out, this txn-scoped cancellation is likely a leftover from ancient times and is no longer needed. In particular, this also fixes the bug of using the span after it was finished (which would occur with high vmodule on `context.go` file). Release note: None
39b7178
to
cf69a32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @andreimatei and @mgartner)
pkg/sql/exec_util.go
line 2294 at r1 (raw file):
Previously, andreimatei (Andrei Matei) wrote…
I think finishing
sp
here was better. I think a better fix would be to callst.ex.state.cancel
here, and then overwrite it.
But, actually, I don't understand whyex.state.cancel
exists - why do we have a transaction-level cancelation? There's logically no such thing as canceling a transaction, is there? I think the only use ofstate.cancel
isCANCEL QUERY
, which could do with a statement-level cancel func. A statement-level func I think could be scoped toexecStmtInOpenState
. Then we wouldn't need this more troublesome and unclearly scoped transaction-level cancelation.The transaction-level cancelation might have been a left-over from an ancient time when
a) we had parallel statements (returning nothing
)
b) the TxnCoordSender's heartbeat loop was using a transaction-scoped SQL ctx.
Neither of these are true any more.WDYT?
I think you are right on all points, so I implemented your suggestion. Let's see what the CI says, but I'm optimistic that nothing will break 🤞
Looks like CI is happy, and I like this approach more. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @andreimatei and @mgartner)
TFTRs! bors r+ |
Build failed (retrying...): |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from cf69a32 to blathers/backport-release-22.1-84628: 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.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
This commit removes an old artifact of having a txn-scoped context
cancellation that is performed when finishing the txn. As Andrei points
out, this txn-scoped cancellation is likely a leftover from ancient
times and is no longer needed. In particular, this also fixes the bug of
using the span after it was finished (which would occur with high
vmodule on
context.go
file).Fixes: #83739.
Release note: None