简体   繁体   English

IIS6应用程序池崩溃

[英]IIS6 Application Pool Crash

During recent stress and volume testing, we realized that after 30minutes, all uses gets disconnected from the website. 在最近的压力和容量测试中,我们意识到30分钟后,所有使用都与网站断开了连接。 After event logging, it came to our attention that the application pool crashes. 事件记录后,我们注意到应用程序池崩溃。 Doing some google investigation, apparently in most causes this is due to unhandled exceptions. 做一些谷歌调查,显然在大多数原因,这是由于未处理的异常。

SO when the application crashes, the following exception details are displayed: 因此,当应用程序崩溃时,将显示以下异常详细信息:

An unhandled exception occurred and the process was terminated.

Application ID: DefaultDomain

Process ID: 7852

Exception: System.Runtime.Serialization.SerializationException

Message: Type 'FuseFarm.FrameworkException' in Assembly 'FuseFarm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

StackTrace:    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeObject(Object obj, MemoryStream stm)
   at System.AppDomain.Serialize(Object o)
   at System.AppDomain.MarshalObject(Object o)

I have no idea why it's trying to Serialize FrameworkException, and I can't see in the code where this is being done either. 我不知道为什么要尝试序列化FrameworkException,而且在代码中也看不到这样做的位置。 But I do see several parts of code where 但是我确实看到了代码的几个部分

new FrameworkException(exData, "ContractComposition.SubmitContract");

is being called, but not being handled. 被调用,但未被处理。 After checking the global.asax.cs, the following is happening: 检查global.asax.cs之后,发生了以下情况:

protected void Application_Error(object sender, EventArgs e)
{
    ILog log = LogManager.GetLogger(typeof(Global));
    string environmentName = WebConfigurationManager.AppSettings["EnvironmentName"];
    if (!String.IsNullOrEmpty(environmentName) && (environmentName == "DEMO" || environmentName == "LIVE"))
    {
        Exception currentException = Server.GetLastError().GetBaseException();
        Session["errorMessage"] = currentException.Message;
        Session["errorSource"] = currentException.Source;
        Session["errorTrace"] = currentException.StackTrace;
        log.Error(currentException.Message, currentException);
        if (currentException != null)
        {
            Session["error"] = currentException.GetType().Name;
            switch (currentException.GetType().ToString())
            {
                case "System.ApplicationException":
                case "FuseFarm.FrameworkException":
                    break;
                default:
                    new FrameworkException(currentException.Message + "\n" + currentException.StackTrace, currentException.Source, currentException);
                    break;
            }

        }
        Server.Transfer("~/error.aspx");
    }
}

Throwing a new exception in Application_Error... This doesn't seem right? 在Application_Error中引发新异常...这似乎不对吗? Who and what will handle this error if it's thrown at this point? 如果此时抛出此错误,谁来处理?

It's Serializing FrameworkException because it is trying to go across an AppDomain boundary. 这是Serializing FrameworkException因为它试图越过AppDomain边界。

All objects that go across an AppDomain must be serialized, and an exception is no different. 遍历AppDomain的所有对象都必须序列化,并且例外没有什么不同。

You can consider it a bug when an Exception does not properly implement serialization. 当异常未正确实现序列化时,您可以将其视为错误

I don't believe that your error handler is what is the source of the problem. 我不认为您的错误处理程序是问题的根源。 It's hard to tell given that stack trace - a full memory dump would yield better information. 考虑到堆栈跟踪,很难说-全内存转储会产生更好的信息。

Your best bet is to just properly make the exception serializable . 最好的选择是适当地使异常可序列化

This may not completely resolve your issue - boiled down, you will still be throwing exceptions. 这可能无法完全解决您的问题-归根结底,您仍然会抛出异常。 Hopefully once that is corrected you will see the real cause of the problem. 希望一旦更正后,您将看到问题的真正原因。

If an exception is thrown in Application_Error, your app pool will crash, just like you're seeing. 如果在Application_Error中引发异常,则您的应用程序池将崩溃,就像您看到的一样。 Based on the code you've shown, I would conclude that the error logger referred to in the line: 根据您显示的代码,我可以得出结论,该行中提到了错误记录器:

log.Error(currentException.Message, currentException);

is attempting to serialize exceptions that are passed into it. 正在尝试序列化传递给它的异常。 When currentException ends up being of type FuseFarm.FrameworkException , the error handler crashes on that line and your app pool shuts down. currentException最终为FuseFarm.FrameworkException类型FuseFarm.FrameworkException ,错误处理程序将在该行崩溃,并且您的应用程序池将关闭。

If this is the case, you'll need to either mark FuseFarm.FrameworkException as Serializable , change the logger to not attempt to serialize objects, or put a try/catch block in the Application_error handler and do something else with those exceptions if you wish the app pool to keep going. 在这种情况下,您需要将FuseFarm.FrameworkException标记为Serializable ,更改记录器以不尝试序列化对象,或者将try / catch块放入Application_error处理程序中,并根据需要对这些异常执行其他操作应用程序池继续前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM