How to protect application pools from session serialization exceptions?

五迷三道 提交于 2019-12-03 07:25:43

We were able to resolve this issue with the help of SOSS technical support – they were tremendously helpful – here are the details:

  • Upon session expiry, SOSS raises an expiration event in its client libraries, which in turn are responsible for firing Session_End in Global.asax (N.B: ScaleOut load balances expiration events across clients, so the web server that created the session may not necesarily receive its expiration event - this is critical for trying to reproduce these issues).
  • Because this happens outside the context of a request, the exception is unhandled and kills the app pool;
  • It’s an extremely uncommon scenario but one that they will nonetheless address in upcoming maintenance releases;
  • The remedies are as follows:

    1. Fix the System.Exception-derived type (that’s serializable but not unserializable);

    2. Remove Session_End events in Global.asax or disable the expiration events (max_event_retries set to 0 in soss_params.txt);

    3. In these scenarios, it’s likely that the user encounters a SerializationException on one of their requests, meaning it reaches Application_Error; here you can clear the session keys (must clear all of them) or abandon the session outright;

    4. Subscribe to AppDomain.UnhandledException to be notified of unhandled exceptions, should they occur (no recourse here, just logging); they can also be disabled via legacyUnhandledExceptionPolicy (not recommended);

Can we trap errors that happen at this step to protect the app pool? The exceptions raised here are logged w/ Source=ASP.NET 2.0.50727.0 and don't reach the application error handlers in global.asax. What can we do to guard against this scenario, even after appropriate checks & balances are applied to session-bound objects?

I don't know if this will work, but you can give it a shot

I fixed this by simply removing the SessionEnd methods completely. It isn't enough to remove the contents of the methods as Asp.net searches for the existence of the method using reflection and then runs the offending code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!