【问题描述】:
产品中某业务功能A,在进行“刷新”—>选择制单—>新增—>切换其他行等一系列操作后,突然发生客户端不响应的现象。
经反复测试验证发现,在单用户场景下也会发生,不过一旦客户端启用了Fiddler工具,此问题便无法重现。并且问题发生后,抓取应用服务器的dump文件进行分析,未发现running状态的线程。
【分析过程】:
根据问题描述初步判定原因在客户端或网络环境上,因此决定采用客户端抓取dump并同时进行网络抓包。在问题重现后,抓取客户端的dump文件,发现客户端的堆栈信息中可以看到,获取Stream后等待流完成。windbg日志如下:
0:000> !clrstack PDB symbol for clr.dll
not
loaded OS Thread Id: 0x3bf8 (0) Child SP IP
Call
Site 0030e658 77860159 [
HelperMethodFrame_1OBJ:
0030e658] System.Threading.WaitHandle.WaitOneNative(System.Runtime.InteropServices.SafeHandle, UInt32, Boolean, Boolean) 0030e73c 6f5d56b1 System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle,
Int64, Boolean, Boolean) 0030e754 6f5d5684 System.Threading.WaitHandle.WaitOne(
Int32
, Boolean) 0030e768 6ea04ef5 System.Net.LazyAsyncResult.WaitForCompletion(Boolean) 0030e798 6ea326ab System.Net.Connection.SubmitRequest(System.Net.HttpWebRequest, Boolean) 0030e7e4 6ea30948 System.Net.ServicePoint.SubmitRequest(System.Net.HttpWebRequest, System.String) 0030e820 6ea30215 System.Net.HttpWebRequest.SubmitRequest(System.Net.ServicePoint) 0030e84c 6ea567d4 System.Net.HttpWebRequest.GetRequestStream(System.Net.TransportContext ByRef) 0030e890 6ea5659e System.Net.HttpWebRequest.GetRequestStream() 0030e898 076f30c6 xxxxxx.Platform.AppFramework.RestfulClientService.HttpRequestNetConnection.Invoke(xxxxxx.Platform.AppFramework.Service.GSPState, System.String, System.String, System.String, Boolean, System.String[]) 0030e90c 076f3044 xxxxxx.Platform.AppFramework.Service.InvokeService.Invoke(xxxxxx.Platform.AppFramework.Service.GSPState, System.String, System.String, System.String, Boolean, System.String[]) 0030e954 1dc33a38 xxxxxx.Platform.XForm.FormWebServiceClient.FormDataAccessServiceProxy.GetObjectXmlByQueryTypeWithParameters(System.String, System.Object, Int32, System.String ByRef, xxxxxx.Platform.AppFramework.Service.GSPState) 0030e978 1dc33917 xxxxxx.Platform.XForm.FormWebServiceClient.FormDataAccessServiceClient.GetObjectXml(System.String, System.Object, xxxxxx.Platform.Engine.DataAccess.ClientSPI.DataQueryType, xxxxxx.Platform.XForm.SPI.TransferState, xxxxxx.Platform.AppFramework.Service.GSPState) 0030e9a0 1dc338c7 xxxxxx.Platform.XFormEngine.Core.ResourceFetcher.GetInstanceXml(System.String, System.Object, xxxxxx.Platform.Resource.Metadata.DataModel.ModelView, xxxxxx.Platform.XForm.SPI.TransferState, xxxxxx.Platform.AppFramework.Service.GSPState) 0030e9c4 1eff4b38 xxxxxx.Platform.XFormEngine.Core.ResourceFetcher.GetInstanceXml(xxxxxx.Platform.XForm.SPI.DataURI, System.String, xxxxxx.Platform.Resource.Metadata.DataModel.ModelView, xxxxxx.Platform.XForm.SPI.TransferState, xxxxxx.Platform.AppFramework.Service.GSPState) 0030e9ec 1eff1614 xxxxxx.Platform.XFormEngine.MLFC.XFML.DOM.InstanceElement.LoadInstanceData(xxxxxx.Platform.XForm.SPI.DataURI) 0030ea44 1eff0c08 xxxxxx.Platform.XFormEngine.MLFC.XFML.DOM.InstanceElement.LoadData(xxxxxx.Platform.XForm.SPI.DataURI) 0030ea7c 1dc33731 xxxxxx.Platform.XFormController.ModelController.CardModelController.LoadData(System.Data.DataRow, Boolean) 0030eaa0 1dc335d2 xxxxxx.Platform.XFormController.FormController.Basic.TreeController.Tree_SelectedChanged(System.Object, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs) 0030eac0 000bd7a7 [MulticastFrame:
0030eac0] DevExpress.XtraTreeList.FocusedNodeChangedEventHandler.Invoke(System.Object, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs) 0030eaec 1e06fdfd xxxxxx.Platform.XFormEngine.MLFC.XFML.DOM.TreeElement.OnSelectedNodeChanged(DevExpress.XtraTreeList.FocusedNodeChangedEventArgs) 0030eb00 1e06fd54 xxxxxx.Platform.XFormEngine.MLFC.XFML.DOM.TreeElement.VisualComponent_FocusedNodeChanged(System.Object, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs) 0030eb14 16434f98 DevExpress.XtraTreeList.TreeList.RaiseFocusedNodeChanged(DevExpress.XtraTreeList.Nodes.TreeListNode, DevExpress.XtraTreeList.Nodes.TreeListNode) 0030eb2c 1dec1c32 DevExpress.XtraTreeList.TreeList.InternalSetFocusedRowIndex(
Int32) 0030eb74 1dec1590 DevExpress.XtraTreeList.TreeList.set_FocusedRowIndex(Int32) 0030eb84 1e05b27e DevExpress.XtraTreeList.Handler.TreeListHandler+NodePressedState.ChangeSelection(DevExpress.XtraTreeList.ViewInfo.RowInfo) 0030ebac 1e05b038 DevExpress.XtraTreeList.Handler.TreeListHandler+NodePressedState.Init() 0030ebd0 162dfe7e DevExpress.XtraTreeList.Handler.TreeListHandler.SetControlState(DevExpress.XtraTreeList.TreeListState) 0030ebe0 1e05aeff DevExpress.XtraTreeList.Handler.TreeListHandler+NormalState.OnPressNode() 0030ebe4 1e05adc0 DevExpress.XtraTreeList.Handler.TreeListHandler+NormalState.MouseDown(System.Windows.Forms.MouseEventArgs, DevExpress.XtraTreeList.TreeListHitTest) 0030ec0c 1e05ac52 DevExpress.XtraTreeList.Handler.TreeListHandler.OnMouseDown(System.Windows.Forms.MouseEventArgs) 0030ec34 1e05abca DevExpress.XtraTreeList.TreeList.OnMouseDown(System.Windows.Forms.MouseEventArgs) 0030ec58 557f09bb System.Windows.Forms.Control.WmMouseDown(System.Windows.Forms.Message ByRef, System.Windows.Forms.MouseButtons, Int32) 0030ec74 552e57d3 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef) 0030ec78 16431287 [InlinedCallFrame:
0030ec78] 0030ecb8
16431287
DevExpress.XtraEditors.Container.EditorContainer.WndProc(System.Windows.Forms.Message ByRef) 0030eccc 164311a5 DevExpress.XtraTreeList.TreeList.WndProc(System.Windows.Forms.Message ByRef) 0030ecdc 552e5263 System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef) 0030ece4 552e51e1 System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef) 0030ecf8 552e50f6 System.Windows.Forms.NativeWindow.Callback(IntPtr,
Int32, IntPtr, IntPtr) 0030ee84 000cd30a [InlinedCallFrame:
0030ee84] 0030ee80 5530548c DomainBoundILStubClass.IL_STUB_PInvoke(MSG ByRef) 0030ee84 552f6292 [InlinedCallFrame: 0030ee84] System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef) 0030eeb8 552f6292 System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32,
Int32) 0030eebc 552f5e6a [InlinedCallFrame:
0030eebc] 0030ef44 552f5e6a System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(
Int32, System.Windows.Forms.ApplicationContext) 0030ef88 552f5bd0 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext) 0030efb4 55286981
System.Windows.Forms.Application.Run(System.Windows.Forms.Form) 0030efc8 1e72c14f xxxxxx.Platform.AppFrameworkGui.Commands.StartWorkbenchCommand.Run(System.String[]) 0030efdc 12b8b5d6 ***
WARNING:
Unable to verify checksum for GSFramework.exe *** ERROR: Module load completed but symbols couldnot
be loaded for GSFramework.exe xxxxxx.Platform.FrameworkGui.Portal.FrameworkMain.RunApplication() 0030f004 0020c2e5 xxxxxx.Platform.FrameworkGui.Portal.FrameworkMain.Run() 0030f094 00201b05 xxxxxx.Platform.FrameworkGui.Portal.FrameworkMain.Main(System.String[]) 0030f2a0 70461276 [GCFrame: 0030f2a0]
同时打开Network Monitor的网络抓包,结果发现客户端最后的http请求中包含invokeStream的字样。请求文本的内容中包含:XXXXXX.TB.ZXYJ.Com.XXXXXX.TB.ZXYJ.Com.TBDYGXCom.AddLB命名空间、方法等信息。
根据请求中的代码关键字找到客户端dll文件,反射查看代码内容发现,该方法调用了InvokeStream流操作但并未关闭,进而造成客户端挂起。
【问题解决】:
修改代码,使用using或finally关闭流操作,测试验证无问题,问题解决。