sql: Temporarily revert per-statement context forking to address memory leak#17200
Merged
itsbilal merged 1 commit intocockroachdb:masterfrom Jul 24, 2017
Merged
Conversation
Member
petermattis
approved these changes
Jul 24, 2017
Collaborator
petermattis
left a comment
There was a problem hiding this comment.
LGTM
This doesn't cause any tests to fail? Seems like there is a hole in the testing of cancellation.
| // Fork context for this statement. | ||
| queryMeta.ctx, queryMeta.cancel = context.WithCancel(session.Ctx()) | ||
| // TODO(itsbilal): Fork a statement-specific context here, that gets cancelled | ||
| // upon request by user. |
Collaborator
There was a problem hiding this comment.
As mentioned privately, perhaps we should create a new context whenever a transaction starts.
Contributor
Author
|
@petermattis Cancellation still works because |
itsbilal
added a commit
to itsbilal/cockroach
that referenced
this pull request
Jul 27, 2017
This reverts some of the changes made in PRs cockroachdb#17003 and cockroachdb#17200. In particular: 17003 made new contexts for every statement, but didn't cancel them after statement execution, resulting in a memory leak. 17200 did a quick-fix for that memory leak by not forking that context, at the expense of not being able to leverage the context in cancellation. This PR restores the context cancellation behaviour introduced in cockroachdb#17003 , except at the transaction level - cancelling a query closes its transaction's context.
itsbilal
added a commit
to itsbilal/cockroach
that referenced
this pull request
Jul 27, 2017
This reverts some of the changes made in PRs cockroachdb#17003 and cockroachdb#17200. In particular: 17003 made new contexts for every statement, but didn't cancel them after statement execution, resulting in a memory leak. 17200 did a quick-fix for that memory leak by not forking that context, at the expense of not being able to leverage the context in cancellation. This PR restores the context cancellation behaviour introduced in cockroachdb#17003 , except at the transaction level - cancelling a query closes its transaction's context.
itsbilal
added a commit
to itsbilal/cockroach
that referenced
this pull request
Jul 31, 2017
This reverts some of the changes made in PRs cockroachdb#17003 and cockroachdb#17200. In particular: 17003 made new contexts for every statement, but didn't cancel them after statement execution, resulting in a memory leak. 17200 did a quick-fix for that memory leak by not forking that context, at the expense of not being able to leverage the context in cancellation. This PR restores the context cancellation behaviour introduced in cockroachdb#17003 , except at the transaction level - cancelling a query closes its transaction's context.
itsbilal
added a commit
to itsbilal/cockroach
that referenced
this pull request
Aug 1, 2017
This reverts some of the changes made in PRs cockroachdb#17003 and cockroachdb#17200. In particular: 17003 made new contexts for every statement, but didn't cancel them after statement execution, resulting in a memory leak. 17200 did a quick-fix for that memory leak by not forking that context, at the expense of not being able to leverage the context in cancellation. This PR restores the context cancellation behaviour introduced in cockroachdb#17003 , except at the transaction level - cancelling a query closes its transaction's context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original PR: #17003
Not cancelling the context right after forking it was causing a memory leak. Simply cancelling the context after every statement doesn't work, since the heartbeat loop detects it and prematurely aborts the transaction (see the comment here).
While I work on a fix, here's a direct revert of just that part of the PR.