[英]IIS6 Application Pool Crash
在最近的壓力和容量測試中,我們意識到30分鍾后,所有使用都與網站斷開了連接。 事件記錄后,我們注意到應用程序池崩潰。 做一些谷歌調查,顯然在大多數原因,這是由於未處理的異常。
因此,當應用程序崩潰時,將顯示以下異常詳細信息:
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)
我不知道為什么要嘗試序列化FrameworkException,而且在代碼中也看不到這樣做的位置。 但是我確實看到了代碼的幾個部分
new FrameworkException(exData, "ContractComposition.SubmitContract");
被調用,但未被處理。 檢查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");
}
}
在Application_Error中引發新異常...這似乎不對嗎? 如果此時拋出此錯誤,誰來處理?
這是Serializing FrameworkException
因為它試圖越過AppDomain邊界。
遍歷AppDomain的所有對象都必須序列化,並且例外沒有什么不同。
當異常未正確實現序列化時,您可以將其視為錯誤 。
我不認為您的錯誤處理程序是問題的根源。 考慮到堆棧跟蹤,很難說-全內存轉儲會產生更好的信息。
最好的選擇是適當地使異常可序列化 。
這可能無法完全解決您的問題-歸根結底,您仍然會拋出異常。 希望一旦更正后,您將看到問題的真正原因。
如果在Application_Error中引發異常,則您的應用程序池將崩潰,就像您看到的一樣。 根據您顯示的代碼,我可以得出結論,該行中提到了錯誤記錄器:
log.Error(currentException.Message, currentException);
正在嘗試序列化傳遞給它的異常。 當currentException
最終為FuseFarm.FrameworkException
類型FuseFarm.FrameworkException
,錯誤處理程序將在該行崩潰,並且您的應用程序池將關閉。
在這種情況下,您需要將FuseFarm.FrameworkException
標記為Serializable
,更改記錄器以不嘗試序列化對象,或者將try / catch塊放入Application_error
處理程序中,並根據需要對這些異常執行其他操作應用程序池繼續前進。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.