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

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: 21/Dec/17 10:23 AM
Component/s: ADO.NET Provider
Affects Version/s:
Fix Version/s:

Environment: Any
Issue Links:

 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 ( 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.