doc icon indicating copy to clipboard operation
doc copied to clipboard

Document the new timeout and cancellation behavior

Open roji opened this issue 6 years ago • 3 comments

  • Soft (server-side) vs. hard (client-side) cancellation
  • Cancellation timeout (in the connection string params page as well)
  • Timeouts are per-operation, the cancellation token isn't stored internally.
    • This means you must call Read/NextResult with the token to actually trigger the cancellation (see https://github.com/npgsql/npgsql/issues/4542)
    • But just one Read/NextResult might not work, since if it has the data buffered, it ignores the token entirely.
    • So the guidance should always be to consume the reader until the end.
  • And are not aggregated (https://github.com/npgsql/npgsql/issues/1041)
  • Nothing (yet) supported in multiplexing
  • Describe statement_timeout and where it's problematic, and also how to configure it on the connection string (https://github.com/npgsql/efcore.pg/issues/2486#issuecomment-1231923351)

roji avatar Sep 18 '20 14:09 roji

@roji we've ran into the the same misunderstanding as in https://github.com/npgsql/npgsql/issues/4542#issuecomment-1173920910 of whether a "cancelled" NpgSqlReader ignores the remaining data in the pipe when disposed or reads to the end.

What stops you from updating the documentation?

baal2000 avatar Sep 17 '25 17:09 baal2000

What stops you from updating the documentation?

Nothing, except time and priority constraints.

roji avatar Sep 18 '25 06:09 roji

Understand.

Just as a suggestion: when this happens, please expand on NpgsqlDataReader.Close and NpgsqlDataReader.CloseAsync by posting a remark similar to SqlDataReader.Close:

...This may be a long operation depending on the amount of data to be consumed...

and

...the time to close may be shortened by calling the Cancel method of the associated SqlCommand object before the Close method is called...

baal2000 avatar Sep 18 '25 11:09 baal2000