Issue Details (XML | Word | Printable)

Key: DNET-787
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jiri Cincura
Reporter: Johannes Lochmann
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
.NET Data provider

Connection Pool fails to handle system time changes correctlry

Created: 03/Oct/17 08:45 AM   Updated: 12/Oct/17 12:00 PM
Component/s: ADO.NET Provider
Affects Version/s: 5.9.1.0
Fix Version/s: 5.12.0.0

Environment: Any


 Description  « Hide
FbConnectionPoolManager's check if a connection is alive fails if the system time travels back in time (changing time zones or daylight saving times while the application is running, for example)

Comparing the absolute difference of the values after adding the connectionLifeTime to the created time should fix the problem.

static bool IsAlive(long connectionLifeTime, DateTimeOffset created, DateTimeOffset now)
{
  if (connectionLifeTime == 0)
    return true;
  return created.AddSeconds(connectionLifeTime) > now;
}

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jiri Cincura added a comment - 09/Oct/17 07:30 AM
Comparing absolute value isn't a solution, because the shortening/lengthening of the lifetime might still happen in case of time shift. Probably something like Stopwatch or Environment.TickCount will be needed.

Jiri Cincura added a comment - 09/Oct/17 03:31 PM
I did some sketch with using Environment.TickCount (https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient/compare/dnet787). Of course this solves the problem of time shifts because of i.e. NTP synchronizations or DST. But also has potential failure when somebody would have connections in pool for longer than 49.7 days. Not sure whether it's really a problem.