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, pgwire: cancel sessions better #30813

Merged
merged 2 commits into from
Oct 1, 2018

Conversation

andreimatei
Copy link
Contributor

Before this patch, cancel session <foo> would cause a connExecutor's
context to be canceled. This patch switches it to cancel the pgwire
connection's ctx instead (which was a parent of the connExecutor's ctx;
now the two are the same), as nature intended. For example, reading from
the network connection should stop ASAP after cancel session. It also
opens to door to guaranteeing that the client using the respective
session is unblocked in a timely manner (by the server closing the
network connection), although that is not currently implemented (pgwire
will still wait for the connExecutor to react to cancelation and finish
its task before closing the net.Conn).
This patch also eliminates what I presume to have been a crash when
someone tries to cancel a "session" created by the InternalExecutor. It
will now be a no-op.
This patch also moves a cancelation callback out of
connExecutor.ctxHolder. I'm trying to get rid of that guy, which is how
this patch came to be.

I've also added a TODO with some thoughts on a better design for session
cancelation, originally expressed in
#23861 (comment).
FWIW, I've tried to be the change, but gave up for the moment.

Release note: None

... and comments around the SessionRegistry.

Release note: None
Before this patch, `cancel session <foo>` would cause a connExecutor's
context to be canceled. This patch switches it to cancel the pgwire
connection's ctx instead (which was a parent of the connExecutor's ctx;
now the two are the same), as nature intended. For example, reading from
the network connection should stop ASAP after `cancel session`. It also
opens to door to guaranteeing that the client using the respective
session is unblocked in a timely manner (by the server closing the
network connection), although that is not currently implemented (pgwire
will still wait for the connExecutor to react to cancelation and finish
its task before closing the net.Conn).
This patch also eliminates what I presume to have been a crash when
someone tries to cancel a "session" created by the InternalExecutor. It
will now be a no-op.
This patch also moves a cancelation callback out of
connExecutor.ctxHolder. I'm trying to get rid of that guy, which is how
this patch came to be.

I've also added a TODO with some thoughts on a better design for session
cancelation, originally expressed in
cockroachdb#23861 (comment).
FWIW, I've tried to be the change, but gave up for the moment.

Release note: None
@andreimatei andreimatei requested review from a team October 1, 2018 04:35
@cockroach-teamcity
Copy link
Member

This change is Reviewable

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: thanks!

Reviewed 2 of 2 files at r1, 2 of 2 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

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

bors r+

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@craig
Copy link
Contributor

craig bot commented Oct 1, 2018

Build failed

Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

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

bors r+

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

craig bot pushed a commit that referenced this pull request Oct 1, 2018
30813: sql, pgwire: cancel sessions better r=andreimatei a=andreimatei

Before this patch, `cancel session <foo>` would cause a connExecutor's
context to be canceled. This patch switches it to cancel the pgwire
connection's ctx instead (which was a parent of the connExecutor's ctx;
now the two are the same), as nature intended. For example, reading from
the network connection should stop ASAP after `cancel session`. It also
opens to door to guaranteeing that the client using the respective
session is unblocked in a timely manner (by the server closing the
network connection), although that is not currently implemented (pgwire
will still wait for the connExecutor to react to cancelation and finish
its task before closing the net.Conn).
This patch also eliminates what I presume to have been a crash when
someone tries to cancel a "session" created by the InternalExecutor. It
will now be a no-op.
This patch also moves a cancelation callback out of
connExecutor.ctxHolder. I'm trying to get rid of that guy, which is how
this patch came to be.

I've also added a TODO with some thoughts on a better design for session
cancelation, originally expressed in
#23861 (comment).
FWIW, I've tried to be the change, but gave up for the moment.

Release note: None

Co-authored-by: Andrei Matei <[email protected]>
@craig
Copy link
Contributor

craig bot commented Oct 1, 2018

Build succeeded

@craig craig bot merged commit 527a8f6 into cockroachdb:master Oct 1, 2018
@andreimatei andreimatei deleted the cancel-session branch October 2, 2018 18:37
@knz
Copy link
Contributor

knz commented Oct 5, 2018

I would recommend a backport for this.

@knz
Copy link
Contributor

knz commented Oct 5, 2018

(To go together with #31002)

@andreimatei
Copy link
Contributor Author

andreimatei commented Oct 5, 2018 via email

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.

3 participants