Repository navigation
Closed
Description
Hi, i use version(4.1.4) from GitHUb> Fix4.1.4 branch,
I get this Exception, after execution application that call single select query.
that this occurs only when the I was open connection to excute SQL Command
SQL Command:Select payment.payment_id,payment.customer_id,payment.staff_idFrom public.payment
Exception message:
This Stack trace:
Npgsql.PostgresException
HResult=0x80004005
Message=57014: canceling statement due to user request
Source=Npgsql
StackTrace:
at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext() in F:\postgresSQL\npgsql\src\Npgsql\NpgsqlConnector.cs:line 940
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext() in F:\postgresSQL\npgsql\src\Npgsql\NpgsqlConnector.cs:line 968
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Npgsql.NpgsqlDataReader.<NextResult>d__44.MoveNext() in F:\postgresSQL\npgsql\src\Npgsql\NpgsqlDataReader.cs:line 500
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Npgsql.NpgsqlDataReader.<Consume>d__64.MoveNext() in F:\postgresSQL\npgsql\src\Npgsql\NpgsqlDataReader.cs:line 793
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Npgsql.NpgsqlDataReader.<Close>d__69.MoveNext() in F:\postgresSQL\npgsql\src\Npgsql\NpgsqlDataReader.cs:line 848
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Npgsql.NpgsqlDataReader.Close() in F:\postgresSQL\npgsql\src\Npgsql\NpgsqlDataReader.cs:line 817
Further technical details
Npgsql version:4.1.4.0
PostgreSQL version:PostgreSQL 11.3 (Debian 11.3-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
Operating system: Windows 10 Enterprise
Metadata
Metadata
Assignees
Labels
No labels
Activity
roji commentedon Jul 5, 2020
The exception indicates that someone is cancelling your query (e.g. by calling NpgsqlCommand.Cance or triggering a cancellation token), but it's not possible to know who that is only from the exception trace posted above. Any chance you can post a minimal code sample that shows the error? Also, are you using any additional layers on top of Npgsql (e.g. Dapper)?
YohDeadfall commentedon Jul 5, 2020
It's possible that the command was cancelled even by a different instance of the application if pgbouncer is used with enabled pooling. Why so? To cancel a command you need the second connection because of the nature of PostgreSQL, and the connection Id is required too. The driver remembers the received id, but it's a physical id which doesn't correspond to the current connection from bouncer.
jemiller0 commentedon Dec 1, 2020
There is something to watch out for regarding this error. I've seen the error when using Dapper and iterating over a result set using a foreach. The results are being read a row at a time (not read into an array/list and then iterated over). The exception below results in an NpgsqlException (the one you list above) in my global exception handler that is outside the foreach loop. To see the actual exception, I found that I have to put a try/catch block within the foreach loop itself. So, I think the exception can still appear even if the connection wasn't cancelled on the back end. Though I think I am actually running into that problem also (intermittent dropped connections when querying a PostgreSQL instance in Amazon's cloud). I just tested it by intentionally throwing an exception in the body of the foreach to see what kind of exception is throw to the global exception handler I have in my Main() method.
jemiller0 commentedon Dec 1, 2020
I think the behavior that I'm seeing may actually be a bug. Here's my stack trace. The problem is that Dispose() is throwing an exception. The rules for Dispose() say that it should never throw an exception if I remember correctly.
roji commentedon Dec 2, 2020
@jemiller0 which version of Npgsql are you using? #2372 should have taken care of this for 5.0.0. Regardless, can you please open a separate issue if there's a problem?
jemiller0 commentedon Dec 2, 2020
Thanks @roji. I'm using .NET Framework. It looked like 5.0.0 required .NET 5. So, I'm currently using 4.1.6.
YohDeadfall commentedon Dec 2, 2020
Don't be cheated by the version number. It's accidentally aligned with .NET 5 because Microsoft skipped version for due to .NET Framework. The provider is available for .NET Standard 2 and above.
jemiller0 commentedon Dec 2, 2020
Thanks @YohDeadfall. I can confirm that 5.0.0 does indeed appear to fix the problem. I like the new behavior much better. The old behavior was very confusing.
YohDeadfall commentedon Dec 2, 2020
Good, closing the issue then.
jemiller0 commentedon Dec 2, 2020
@YohDeadfall I don't know if it fixes the problem that @jack0718 had when he created this issue. Mine was actually the one in #2372.
jemiller0 commentedon Dec 2, 2020
@roji @YohDeadfall I just wanted to say, I think you guys are doing a great job. I can't remember what the other issues were, but, I ran into a weird issue here or there and remember @roji responding and problems being fixed. It is very refreshing to run into a problem like the one with Dispose() throwing exceptions and having developers fix it straight away. This stands in stark contrast to a lot of other projects that I've had experience with. So, thanks, and keep up the good work.
YohDeadfall commentedon Dec 2, 2020
Mostly all cancellation stuff was made by @vonzshik, he did a lot just before 5.0 and now is a member of the crew. Another big feature was made by @Brar, it's replication support. So it's not just Shay and me (: Anyway, thank you for the kind words!
roji commentedon Jan 17, 2021
Closing as no responses were provided for the original issue by @jack0718.
MuniprasadAN commentedon May 28, 2024
For me , its timeout.