我們發現部分生產服務器存在間歇性問題。間歇性地說,我的意思是,目前影響到我們總運行量的不到1%,並且僅在我們的〜20臺服務器中有兩臺顯示(我們至少注意到了這一點)。web服務客戶端出現間歇性錯誤
我們的設置是這樣的: 我們有一個自定義的軟件,它是舊的VB6和C#.net代碼的混蛋版本。該計劃是我們自己內部腳本的網頁掃描引擎。該程序通過服務器園區執行,每個服務器一次運行50-150個實例,每個實例都有一個單獨的腳本。
會發生什麼情況是,初次加載後,問題中的程序會嘗試聯繫web服務以獲取設置集合。偶爾,我們得到這個問題:
System.IO.FileNotFoundException:
Could not find file 'C:\Documents and Settings\ccrun\Local Settings\Temp\driumfrd.dll'. File name: 'C:\Documents and Settings\ccrun\Local Settings\Temp\driumfrd.dll'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
...
我們的記錄極限在此之後被擊中。 .dll名稱在每次執行時都不相同。這是遠離VB6代碼的2層間接方向,所以我相當肯定這是一個純粹的C#問題 到目前爲止,我在Google上能夠找到的是,這與Web的動態編譯有關服務客戶端代碼。我的google-fu在什麼地方停下來是爲了找出爲什麼我們不會一直得到這個錯誤。權限不能錯,因爲並非所有的工作都失敗。在同一臺服務器上重新啓動時,完全相同的作業將完成而不會出現任何錯誤。
我們唯一能夠辨別的指標是作業通常在集羣中失敗,其中大多數(但不是所有)作業同時啓動(並且在同一臺服務器上)會失敗。除此之外,我們在這裏沒有什麼好處。
到目前爲止,我已經找到最好的鏈接是這樣的: http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/d7ea81e7-8fea-4056-ad21-f2fee1887bcc
編輯: 這是非常非常奇怪,經過一番補充調查我發現,在我們的日誌中的錯誤信息有錯誤的錯誤代碼。
public entry_function()
{
try
{
do stuff..
main_function();
}
catch (Exception exp)
{
// General error
_log.EventID = 57051;
_log.WriteToErrorLog(Log.Level.ERROR, "Unhandled exception", exp);
}
}
public main_function()
{
do more stuff...
helper function();
}
public helperfunction()
{
try
{
switch()
{
...
case WebServices.WSMarkAsInvalid:
{
// Info logger
_log.EventID = 57114;
_log.WriteToInfoLog(Log.Level.INFO, "Call WSMarkAsInvalid start");
new WSSystem.WSSystem().WSSystemMarkAsInvalid((string)parameters[0], (string)parameters[1], (int)parameters[2]);
// Info logger
_log.EventID = 57115;
_log.WriteToInfoLog(Log.Level.INFO, "Call WSMarkAsInvalid end");
return null;
}
}
}
catch(Exception exp)
{
_log.EventID = 57120;
_log.WriteToErrorLog(Log.Level.WARN, "Error communicating with webservice", exp);
}
}
無視明顯的僞代碼位,我看到4箱子其中57114之後是57120警告和39情況下,57114是57051跟着!
儘管匹配了「任何」異常,但我完全不知所措,儘管我可以說,內部try/catch沒有被擊中。
編輯看來,我們運行的內部try/catch(exception)語句實際上並沒有捕獲所有拋出的異常! – Grubsnik 2011-12-22 14:41:18