SCM

[#1011136] CommandTimeout has a surprising maximum value, and overflows

View Trackers | Bugs | Download .csv | Monitor

Date:
2011-12-16 23:31
Priority:
3
State:
Closed
Submitted by:
Matthew Gabeler-Lee (cheetah)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.11
Category:
None
Group:
None
Resolution:
Accepted
Summary:
CommandTimeout has a surprising maximum value, and overflows

Detailed description
Because it gets passed to Socket.Poll as a signed 32 bit integer number of microseconds, the CommandTimeout property has a surprising maximum value, and it silently overflows and wraps around. Depending on what value you pass, this can either cause it to use a very short timeout, or an infinite timeout.

The call to Socket.Poll in NpgsqlState.cs, around line 357, needs to be placed in a loop with a wall clock deadline (or something similar) in order for large command timeouts to be obeyed.

Failing that, command timeouts that cannot be represented should cause the property setter to throw an exception.

Followup

Message
Date: 2013-03-10 17:36
Sender: Francisco Figueiredo jr.

Fixed by patch: [#1011316]
Date: 2011-12-17 03:54
Sender: Matthew Gabeler-Lee

One more piece of detail: the value I used was 21600 (6 hours). I also
was able to use a value of 2400 (40 minutes) to cause the overflow to give
a negative value for an infinite timeout.
Date: 2011-12-17 03:31
Sender: Matthew Gabeler-Lee

Sorry for the lack of clarity, I left out an important detail: I'm setting the
property directly in code on an individual NpgsqlCommand object.
Date: 2011-12-17 02:49
Sender: Francisco Figueiredo jr.


I tried to reproduce the problem here by passing a large string value to be used as a command timeout and Convert.ToInt32 complained about a value too large.

I tested this line of code:

case Keywords.CommandTimeout:

this._command_timeout = Convert.ToInt32(value);

break;

On NpgsqlConnectionStringBuilder.cs where it is parsed.

Can you provide me with a test case where you see this problem? This way I can test it here and provide a fix.

Thanks in advance.

Attached Files:

Changes:

Field Old Value Date By
status_idOpen2013-03-10 17:38fxjr
close_dateNone2013-03-10 17:38fxjr
ResolutionNone2013-03-10 17:38fxjr
Powered By FusionForge