Skip to content

Set token when throwing OperationCanceledException - #3253

Merged
roji merged 3 commits into
npgsql:mainfrom
roji:TokensTokensTokens
Oct 25, 2020
Merged

roji merged 3 commits into
npgsql:mainfrom
roji:TokensTokensTokens

Conversation

@roji

@roji roji commented Oct 21, 2020

Copy link
Copy Markdown
Member

Fixes #3252

@roji
roji requested a review from YohDeadfall as a code owner October 21, 2020 14:09
@roji
roji requested a review from vonzshik October 21, 2020 14:09
@vonzshik

Copy link
Copy Markdown
Contributor

Interesting, and what about COPY operations and WaitAsync?

@vonzshik

Copy link
Copy Markdown
Contributor

Also, there might be a different CancellationToken between ExecuteReaderAsync and ReadAsync.

roji referenced this pull request Oct 21, 2020
And a general refactor of how cancellation works
@roji

roji commented Oct 21, 2020

Copy link
Copy Markdown
Member Author

Interesting, and what about COPY operations and WaitAsync?

I've left those out for now since they have their own full-blown work items (e.g. #1328) - but we'd presumably use the same mechanism. I'll add a note to those issues, and let's keep this open as well so we don't forget.

Also, there might be a different CancellationToken between ExecuteReaderAsync and ReadAsync.

Good point.

@vonzshik

Copy link
Copy Markdown
Contributor

Something what came to my mind - how the cancellation should work for the auth?

@roji

roji commented Oct 22, 2020

Copy link
Copy Markdown
Member Author

Also, there might be a different CancellationToken between ExecuteReaderAsync and ReadAsync.

I just pushed a commit which takes care of this, and also adds tests for soft/hard cancellation on NpgsqlDataReader.{ReadAsync,NextResultAsync} (using the PG mock). Can you re-review?

I also noticed that we don't handle cancellation for the async column operations on DbDataReader - GetFieldValueAsync and IsDBNullAsync. Both of these always completely synchronously by default (when CommandBehavior.SequentialAccess isn't set) - this is because the reader buffers entire rows, so all column operations have data in memory and return immediately. This means that we only need to handle cancellation for CommandBehavior.SequentialAccess - I'll work on that soon too (not sure if in this PR though).

Something what came to my mind - how the cancellation should work for the auth?

Good point. There's no PG cancellation at that point of course, so we need to go directly to hard socket cancellation. This is a bit similar to Wait cancellation (there's nothing to cancel).

@vonzshik vonzshik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We now have a thread safety for pending servers and requests, hooray!
All in all, it looks great.

But I do worry about the failed test..

@roji
roji requested a review from vonzshik October 25, 2020 12:34
@roji
roji force-pushed the TokensTokensTokens branch from 8de3d71 to 43d9592 Compare October 25, 2020 13:30
@roji
roji merged this pull request into npgsql:main Oct 25, 2020
@roji
roji deleted the TokensTokensTokens branch October 25, 2020 13:37
@roji

roji commented Oct 25, 2020

Copy link
Copy Markdown
Member Author

Merged via bd3e617

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.

Populate the originating cancellation token in our OperationCanceledExceptions

2 participants