Repository navigation
Fixed possible deadlock when using ExecuteNonQueryAsync - #3666
Conversation
|
That doesn't make a lot of sense - why |
|
Note also that the reader is already consumed, since the previous line calls NextResult until it returns false. Unless I'm mistaken, that pretty much guarantees that no I/O will actually happen from within the Close (haven't verified this). But this change isn't necessarily a bad idea either... |
There will be no IO, as by this point we've already send every single query and read every single response. Also, note that this part was removed in 5.0. |
Yep, though note that Dispose could have the same problem (in other contexts, not here). In other words, we need to be careful when doing |
|
I have tracked down the issue a little further: The main reason I had a deadlock was because I used a custom Making Note: I am not 100% sure if my explanation is correct. I am not an expert. I have attached a little Program to reproduce the deadlock. It basically just tries to execute as many Update Sqls as possible at the same time. At work it only took me 100 requests where about 5-10 deadlocked. At home I needed 1000 requests. |
|
@rhintersteininger ah, I see - now that makes total sense. In your case, the In this case, I do agree with this fix - although, we would have to be a little bit creative for 5.0 (and 6.0). Also, we have to check other places for the same problem (I'm going to do this later). |
|
Note #1130 which is also a case of a custom TaskScheduler causing issues (in Orleans). |
The async parameter was not passed to the Close Method of the NpgsqlDataReader. This can cause a deadlock in the Cleanup Method of the DataReader because it is actively waiting for the completion of the "_sendTask".
I have tested this with Npgsql 4.1.9, PostgreSQL 10.3