How do I find what queries were executing in a SQL memory dump?-----stack
- NOTE: This post has been updated in a new post due to an issue found with the steps in this post. The procedure is the same, but the steps here may only work with 32 bit dumps. Please read the post located at the address below:
—————————————————————————————————-
In this post, we’ll see how to find out which queries were executing from a SQL Server memory dump. You might have a dump file from a crash of the SQL Service, or you may have taken a diagnostic dump with sqldumper.
What we do in this post assumes you are working with a full or filtered dump of SQL Server. For more information on dumping SQL Server, read this post:
http://blogs.msdn.com/b/askjay/archive/2010/02/05/how-can-i-create-a-dump-of-sql-server.aspx
Some of the objects contained in the dump that are needed to completely understand this process can only be resolved with private symbols. What this means is that to fully track down the executing query text, you need to be internal to MS with access to “private” symbols.
However, after finding the query text with the private symbols, we can quickly get to the query text with public symbols and a few specific memory addresses and offsets.
So first, set your public symbol path:
0:000> .sympath srv*c:\symbols\public*http://msdl.microsoft.com/download/symbols
Symbol search path is:srv*c:\symbols\public*http://msdl.microsoft.com/download/symbols
0:000> .reload /f sqlservr.exe
Search the stacks:
0:000> ~* k
You are looking for a stack that is executing a query. It will look like this:
Call Site
ntdll!ZwWaitForSingleObject+0xa
KERNELBASE!WaitForSingleObjectEx+0x9c
sqlservr!SOS_Scheduler::Switch+0xc7
sqlservr!ThreadScheduler::SwitchNonPreemptive+0xc6
sqlservr!AutoSwitchPreemptive::~AutoSwitchPreemptive+0x39
sqlservr!SOS_Task::AutoSwitchPreemptive::~AutoSwitchPreemptive+0x26
sqlservr!Np::StatusWriteNoComplPort+0xc3
sqlservr!SNIStatusWriteNoComplPort+0x59
sqlservr!TDSSNIClient::WriteStatus+0x99
sqlservr!write_data+0x1bf
sqlservr!flush_buffer+0xf3
sqlservr!CKatmaiTds::SendRowImpl+0x19c
sqlservr!CEs::GeneralEval+0x91f
sqlservr!CXStmtQuery::ErsqExecuteQuery+0xe3a
sqlservr!CMsqlExecContext::ExecuteStmts<1,1>+0xb6c
sqlservr!CMsqlExecContext::FExecute+0x593
sqlservr!CSQLSource::Execute+0x2f9
sqlservr!process_request+0x370
sqlservr!process_commands+0x2b2
sqlservr!SOS_Task::Param::Execute+0x11b
sqlservr!SOS_Scheduler::RunTask+0xca
sqlservr!SOS_Scheduler::ProcessTasks+0x95
sqlservr!SchedulerManager::WorkerEntryPoint+0x110
sqlservr!SystemThread::RunWorker+0x60
sqlservr!SystemThreadDispatcher::ProcessWorker+0x12c
sqlservr!SchedulerManager::ThreadEntryPoint+0x12f
msvcr80!_callthreadstartex+0x17 [f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c @ 348]
msvcr80!_threadstartex+0x84 [f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c @ 326]
kernel32!BaseThreadInitThunk+0xd
ntdll!RtlUserThreadStart+0x21We are interested in the 3rd parameter of the sqlservr!CMsqlExecContext::ExecuteStmts call as seen below:
0e 00000000`0f6eee80 00000000`00e90fe3 : 00000064`00000000
00000001`00000000
00000000`86909380
00000000`00000000
: sqlservr!CMsqlExecContext::ExecuteStmts<1,1>+0xb6cThis is the address of an object, and we need to dump 1 dword at an offset of 0x20 into this object:
0:041>
dd 86909380+0x020 l1
00000000`869093a0 869093e0The address at this offset into the object is a property that contains a pointer (another address) to the buffer that contains our query text. So we get our address from here:
0:041>
dd 869093e0 l1
00000000`869093e0 86909470Now this is the address we need. So we dump unicode string on this address and we get our query:
0:041>
du 86909470
00000000`86909470 "….select * from Sales.SalesOrd"
00000000`869094b0 "erHeaderroductLevel’);..a"You should be able to follow this approach for most threads executing queries. The signature of the “ExecuteStmts” function (a method of the CMsqlExecContext object) should have the object address we need as the 3rd parameter provided the stack is the same (the method could be overloaded and take something else as the 3rd parameter in a different situation – but I’d have to check).
-Jay
How do I find what queries were executing in a SQL memory dump?-----stack的更多相关文章
- The new powerful SQL executing schedule monthly or weekly in DB Query Analyzer 7.01
1 About DB Query Analyzer DB Query Analyzer is presented by Master Genfeng,Ma from Chinese Mainland. ...
- EF: Raw SQL Queries
Raw SQL Queries Entity Framework allows you to query using LINQ with your entity classes. However, t ...
- BZOJ2482: [Spoj1557] Can you answer these queries II
题解: 从没见过这么XXX的线段树啊... T_T 我们考虑离线做,按1-n一个一个插入,并且维护区间[ j,i](i为当前插入的数)j<i的最优值. 但这个最优值!!! 我们要保存历史的最优值 ...
- SPOJ 1557. Can you answer these queries II 线段树
Can you answer these queries II Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 https://www.spoj.com/pr ...
- [Oracle EBS R12]SQL Queries and Multi-Org Architecture in Release 12 (Doc ID 462383.1)
In this Document Abstract History Details Previous Releases Release 12 Multi-Org Session ...
- bzoj 2482: [Spoj GSS2] Can you answer these queries II 线段树
2482: [Spoj1557] Can you answer these queries II Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 145 ...
- SQL Queries and Multi-Org Architecture in Release 12
In this Document Abstract History Details Previous Releases Release 12 Multi-Org Session ...
- Code Forces 644B Processing Queries
B. Processing Queries time limit per test5 seconds memory limit per test256 megabytes inputstandard ...
- Light OJ-1082 - Array Queries,线段树区间查询最大值,哈哈,水过~~
...
随机推荐
- ogre 3d游戏开发框架指南
ogre 3d游戏开发框架指南pdf 附光盘代码 http://www.ddooo.com/softdown/74228.htm OGRE3D游戏开发框架指南.pdf http://vdisk.wei ...
- 应用程序有bug崩溃重启的案例2
------解决思路----------------------另外做一个服务或者程序定时监控系统进程.程序奔溃的话,都会在入口函数出现异常处理一下winform可以有两个事件来捕获主线程异常和线程异 ...
- Android Studio代码字体模糊解决方法
问题描述: 我的电脑分辨率是(1920*1080),然而安装了Android Studio后代码的一些部分区域出现模糊的现象,应该是软件默认设置与高分屏有冲突. 如下图所示. 解决方法: 打开设置对话 ...
- linux命令(50):top命令
TOP是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占前台,直到用户终止该程序为止.比较准确的说,top命令提供了实时的对系统处理器的状态监视.它将显示系统中C ...
- 一个大div里面包裹一个小div,里面的小div的点击事件不触发外面的这个大div的点击事件
一开始上html代码 <div id="div1" style="background: blue;width: 100px; height: 100px;&quo ...
- redis 安装配置
reids 安装配置 1.1 下载软件包 [root@node01 ~]# mkdir -p /data/src/ [root@node01 ~]# cd /data/src/ [root@node0 ...
- 《逐梦旅程 WINDOWS游戏编程之从零开始》笔记8——载入三维模型&Alpha混合技术&深度测试与Z缓存
第17章 三维游戏模型的载入 主要是如何从3ds max中导出.X文件,以及如何从X文件加载三维模型到DirextX游戏程序里.因为复杂的3D物体,要用代码去实现,那太反人类了,所以我们需要一些建模软 ...
- 微信小程序-ios系统-下拉上拉出现白色,如何处理呢?
这几天做小程序,有些页面都是全屏的背景,在安卓上背景是固定的,而在ios上上拉下拉出现白色,测试说体验不太好,一开始我以为是下拉上拉刷新造成的,关闭了依然是这样.为了体验好点,可以按一下解决: 方式一 ...
- 我一直记不住的vim用法
一.多行编辑进入visual block模式一般模式下Crtl+v组合键以块的形式选中待编辑的文本 进入visual line模式一般模式下大写V以行的形式选中待编辑的文本 上述两种模式的复制用y,删 ...
- bzoj 1444 AC自动机 + 矩阵乘法 | 高斯消元
恶补了一下AC自动机,花了一天时间终于全部搞明白了. 思路:将每个人的串加入AC自动机,在AC自动机生成的状态图上建边,注意单词末尾的节点只能转移到自己概率为1, 然后将矩阵自乘几十次后误差就很小了, ...