Bug #62195 | Unable to switch off cleanup timer and unable to implement Session_End | ||
---|---|---|---|
Submitted: | 17 Aug 2011 16:15 | Modified: | 19 Mar 2013 20:58 |
Reporter: | David Newcomb (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 6.4.3 | OS: | Windows |
Assigned to: | Gabriela Martinez Sanchez | CPU Architecture: | Any |
Tags: | sessionprovider, timeout |
[17 Aug 2011 16:15]
David Newcomb
[31 Oct 2011 20:04]
Reggie Burnett
David I guess I don't understand. The class is not sealed and both Initialize and SetItemExpireCallback can be overridden in your code. You could always reset or disable the timer in your code. SqlSessionStateStore doesn't allow expire callbacks and we are not sure we will either. Perhaps if you explain further what you are trying to do.
[1 Nov 2011 12:13]
David Newcomb
I am running 5 identical IIS applications on 5 nodes in a Microsoft Load Balanced (NLB) cluster. All nodes in the cluster are talking to the same MySQL database. I have configured IIS to store session state in a MySQL database using the web.config file (section: configuration->system.web->sessionState). The type used is MySql.Web.SessionState.MySqlSessionStateStore. All the class variables in the MySqlSessionStateStore type are private and are not accessible from derived classes, so I don't have access to any of the cleanup member variables or timers. I can't cut and paste your Initialise() method because it references private class variables that are not visible. If I derive a class from MySqlSessionStateStore and override the Initialize() method then I will have to call MySqlSessionStateStore/base.Initialize() anyway that starts the timer. At the end of the MySqlSessionStateStore.Initialise() method the driver creates the timer. There is no configuration value I can set in order to switch off your timer. Normally, and in most other drivers, settings a value to zero disables the timer, but in the MySQL driver's case it rounds the value up to 1 and starts the timer regardless. All the nodes in the cluster are stateless and they pick up the session from the database on each request. The IIS session holds references to limited resources (licenses). When the timer expires all the sessions are deleted and nobody is notified, so those resources can not be freed. In order to free these resources before the MySQL connector deletes the expired session records, we have to set the timeout to the maximum value, then run a separate process to interrogate the session records looking for any that have expired, free their resources and delete the session record. This is not ideal because the driver is running a timer that we "hope" never expires and most of that work already lives in your driver. With my somewhat cynical hat on, the SqlSessionStateStore *currently* doesn't allow expire callbacks probably because the MSDN example of how to implement a SessionProvider (of which yours is almost a dead copy) didn't implement it. I have documented how the MySQL .NET connector breaks the MSDN SessionProvider contract under Bug #62266. To precis: if you use IIS's session.timeout (which you do) then you must allow users to get session expiry notifications (which you don't) or not delete the session records (which you do) so we can do our own clean up. Even if I wasn't running in a cluster we (and all your other users) would still have to implement all this functionality to free our session held resources. This bug and Bug #62266 are two separate problems, but together prevent us from cleanly implementing what we need. I linked to the NHSessionStateStoreProvider to show how you might implement it. I used it to help with my implementation (attached to Bug #62266). They use the configuration option "enableExpiredSessionAutoDeletion" to toggle what you are (incorrectly) doing and what we can not switch off. Gabriela Martinez thinks that this is not a bug but a feature request. But is fixing a broken contract a bug?
[7 Nov 2012 11:19]
David Newcomb
Bug 62266 has been fixed and the explanation of the fix appears to fix this bug or at least make it so we don't notice it any more. You can close this issue.
[7 Nov 2012 15:30]
Gabriela Martinez Sanchez
Thanks for your feedback. We'll do some improvements on this functionality targeting 6.7.x version. We'll keep you updated.