Skip to content

Changing sync query timeout exception - #3136

Closed
vonzshik wants to merge 11 commits into
npgsql:devfrom
vonzshik:FixingSyncQueryTimeoutException
Closed

vonzshik wants to merge 11 commits into
npgsql:devfrom
vonzshik:FixingSyncQueryTimeoutException

Conversation

@vonzshik

Copy link
Copy Markdown
Contributor

Closes #3132

@roji roji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.

In addition to the comments below, as long as we're working here, let's do a bit more cleanup:

  • dontBreakOnTimeouts is only set to true when waiting for PG notifications via NpgsqlConnector.{Wait,WaitAsync}. There is no real reason for the exception to be TimeoutException in that case, rather than TimeoutException wrapped by NpgsqlException - we can modify the catch there to identify whatever timeout exception we throw here. The only difference between the two branches should be that when dontBreakOnTimeouts is true, we don't break (as the flag name implies).
  • Once this is done, the sync path (catch IOException) and async path (catch OperationCanceledException) are identical - we can unify them under the catch below and switch on the exception type to de-duplicate the logic once.

Comment thread src/Npgsql/NpgsqlReadBuffer.cs Resolved
Comment thread src/Npgsql/NpgsqlReadBuffer.cs Resolved
@vonzshik

Copy link
Copy Markdown
Contributor Author

@roji done!

Also, something curious I've been able to find: while NpgsqlConnector.Wait does catch the TimeoutException, NpgsqlConnector.WaitAsync does not. Not sure, if this is a bug or not.

@roji

roji commented Sep 12, 2020

Copy link
Copy Markdown
Member

Also, something curious I've been able to find: while NpgsqlConnector.Wait does catch the TimeoutException, NpgsqlConnector.WaitAsync does not. Not sure, if this is a bug or not.

This is because until very recently we didn't have async timeouts at all - you added these in #607 :)

But you're right - we also need to complete async timeout support for WaitAsync. This would probably mean introducing a new overload which accepts the timeout (just like with sync Wait), and make sure to flow it down just like NpgsqlCommand does. It's a good idea to open a new issue to track this - you're of course welcome to work on it.

Comment thread src/Npgsql/NpgsqlReadBuffer.cs Resolved
Comment thread src/Npgsql/NpgsqlWriteBuffer.cs Resolved
Comment thread src/Npgsql/NpgsqlWriteBuffer.cs Resolved
Comment thread src/Npgsql/NpgsqlWriteBuffer.cs Resolved
Comment thread src/Npgsql/NpgsqlConnector.cs Resolved
@vonzshik

Copy link
Copy Markdown
Contributor Author

@roji done again! 😃

@roji

roji commented Sep 12, 2020

Copy link
Copy Markdown
Member

Did a tiny last cleanup and merged this via f6c9508.

Thanks @vonzshik, as always :)

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.

Make an exception for a timeout of a sync query the same way as for an async one

2 participants