SCM

[#1010986] Endless recursion on hanging connection in ProcessBackendResponsesEnum

View Trackers | Bugs | Download .csv | Monitor

Date:
2011-02-03 11:10
Priority:
3
State:
Open
Submitted by:
Stanislav Meduna (numo)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.11
Category:
Group:
Resolution:
None
Summary:
Endless recursion on hanging connection in ProcessBackendResponsesEnum

Detailed description
Npqsql.NpgsqlState.ProcessBackendResponsesEnum will endless recurse if the connection is dead (connected from the TCP/IP view but not returning any response).

Reason:
- "this" is NpgsqlReadyState
- The Mediator.CommandTimeout is 20 (default)
- Socket.Poll times out
- CancelRequest is called
- ProcessBackendResponsesEnum is taken, with the CommandTimeout still 20
- recurse until the connection dies with an exception, firing cancels each 20 seconds

Reproduce-by: suspend the PostgreSQL process processing the first request and submit a query (I am using "select version()")

Followup

Message
Date: 2011-03-15 01:06
Sender: Francisco Figueiredo jr.

Patch applied to cvs.
Date: 2011-03-15 00:57
Sender: Francisco Figueiredo jr.


That's great to hear!

I'll commit the code then.

Thanks for your review...
Date: 2011-03-14 10:30
Sender: Gildas

After one week of tests, no Endless recursion has been encountered... Yeehaah !! :)

I think you can upload to CVS your patch and close this bug.
Date: 2011-03-10 12:12
Sender: Gildas

It seems to work for me. I'll see if it works until Monday to be sure.

Here is the Npgsql logs obtained, I've removed some logs from the previous installed dll in order to have a lightweiht log file...

Reminder : Our commandtimeout is 3600 secs (1h)

10/03/2011 05:08:29.894 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum end of Poll (ok)()
10/03/2011 05:08:30.097 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum end of Poll (ok)()
10/03/2011 05:08:30.300 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum end of Poll (ok)()
10/03/2011 05:08:30.502 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum end of Poll (ok)()
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum end of Poll (err)()
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum going to CancelRequest()
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlConnector.CancelRequest()
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlConnector.CancelRequest - before open()
10/03/2011 06:08:30.709 1628 Normal Connected to: 127.0.0.1:5432.
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlConnector.CancelRequest - after open - before CancelRequest()
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlConnector.CancelRequest - after CancelRequest()
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlConnector.CancelRequest - before close()
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlConnector.CancelRequest - after close()
10/03/2011 06:08:30.709 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum request Canceled()
10/03/2011 07:08:30.724 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum end of Poll (err)()
10/03/2011 07:08:30.724 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum going to throw exception()
10/03/2011 07:08:30.724 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum going to throw exception()
10/03/2011 07:08:30.756 1628 Normal Entering NpgsqlState.ProcessBackendResponsesEnum end of Poll (ok)()
10/03/2011 07:08:30.756 1628 Normal Set NpgsqlParameter.ParameterName = id
10/03/2011 07:08:30.756 1628 Normal Set NpgsqlParameter.NpgsqlDbType = Uuid
10/03/2011 07:08:30.756 1628 Normal Get NpgsqlParameter.ParameterName
10/03/2011 07:08:30.756 1628 Normal Get NpgsqlParameter.ParameterName
Date: 2011-03-04 01:29
Sender: Francisco Figueiredo jr.

I've uploaded the files. Note that this files also contain another patch I've finished to improve connector validity check.
Date: 2011-03-03 22:28
Sender: Gildas

Can you post the patch to this thread please, i haven't worked on it yet... :(

I'll let you know if it works next week, i'll make the tests from Monday until it work's.

Thanks in advance.
Date: 2011-03-03 14:31
Sender: Francisco Figueiredo jr.


I have it implemented here with a little modification.

Instead of creating a set property to CancelRequestCalled, I added code to Connector.CancelRequest to set the internal property to true. So, there is no need for the call context.CancelRequestCalled = true.

Please, let me know if it works for you. If it is ok, I'll commit the code.
Thanks in advance.
Date: 2011-03-03 07:39
Sender: Gildas

Your solution sounds good for me, i'll modify the source code in order to apply your solution, and i'll let you know if it works for me.
Date: 2011-03-01 22:39
Sender: Francisco Figueiredo jr.


I think we will have to add a guard condition just inside the try catch which calls the cancel request. If we are already in the middle of cancel request and times out again we should just return instead of trying to read the response of the cancel request.

It would be something like:

if (!((this is NpgsqlStartupState || this is NpgsqlConnectedState || context.CancelRequestCalled)))

{
try
{
context.CancelRequest();
context.CancelRequestCalled = true;
[...]
}
}

What do you think?
Date: 2011-02-21 11:19
Sender: Gildas

It seems that i've the same problem, i've put some explanations and logs in this thread : http://pgfoundry.org/forum/forum.php?thread_id=10071&forum_id=519

Attached Files:

Attachments:
NpgsqlState.cs.patch
NpgsqlConnector.cs.patch

Changes:

Field Old Value Date By
File Added592: NpgsqlConnector.cs.patch2011-03-04 01:28fxjr
File Added591: NpgsqlState.cs.patch2011-03-04 01:26fxjr
Powered By FusionForge