FIX: You cannot kill a session that is running a query on a linked server in SQL Server 2005 and in SQL Server 2008

Article translations Article translations
Article ID: 961237 - View products that this article applies to.
Microsoft distributes Microsoft SQL Server 2005 or Microsoft SQL Server 2008 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 or Microsoft SQL Server 2008 fix release.
Expand all | Collapse all

On This Page

SYMPTOMS

Symptom 1

In Microsoft SQL Server 2005 or in Microsoft SQL Server 2008, you run a query on a linked server. When you try to kill the session that is running the query, you cannot kill the session. Additionally, the performance of SQL Server becomes very slow.

A minidump file is generated in the SQL Server log folder. If you query the sys.dm_os_waiting_tasks dynamic management view, you receive a result that resembles the following:
session_id request_id  ecid        blocking_session_id blocking_ecid task_state      wait_type      wait_duration_ms     
---------- ----------- ----------- ------------------- ------------- --------------- ------------------------------- 
        14        NULL        NULL                NULL             0 NULL                             0 
        20           0           0                   0             0 SUSPENDED       WRITELOG         1360 
        53           0           0                  58             0 SUSPENDED       LCK_M_S          31982080 
        55           0           0                   0             0 RUNNING                          0 
        58           0           0                   0             0 SUSPENDED       LOGBUFFER        1350 
        59           0           0                   0             0 SUSPENDED       LOGBUFFER        1350 
        60           0           0                   0             0 RUNNING                          0 
        61           0           0                   0             0 SUSPENDED       LOGBUFFER        1350 
        63           0           0                  14             0 SUSPENDED       LCK_M_X          76460 
        66           0           0                   0             0 SUSPENDED       LOGBUFFER        1350 
        68           0           0                   0             0 SUSPENDED       LOGBUFFER        1330 
        70           0           0                   0             0 RUNNING                          0 
        77           0           0                   0             0 SUSPENDED       LOGBUFFER        1350 
        84           0           0                   0             0 SUSPENDED       WRITELOG         1230 
        87           0           0                   0             0 SUSPENDED       WRITELOG         3970 
        88           0           0                   0             0 SUSPENDED       WRITELOG         1210 
Note You must restart the SQL Server service to resolve this issue.

Symptom 2

You might also experience SQLAgent memory growth to unusual sizes. This occurs because a job that SQLAgent schedules executes a stored procedure to a linked server. The stored procedure raises an OLEDB error. The text for the OLEDB error is passed back to SQLAgent, and memory is continually allocated for the text message but never deallocated. This causes SQLAgent memory growth. The indefinate loop causes the large number of memory allocations in SQLAgent.

Call stack information

 # Child-SP          RetAddr           Call Site
00 00000000`1e29c548 00000000`77adccec ntdll!memcpy+0x314 
01 00000000`1e29c550 00000000`77adbed4 ntdll!RtlpReAllocateHeap+0x741 
02 00000000`1e29c800 00000000`73e62504 ntdll!RtlReAllocateHeap+0xa4 
03 00000000`1e29c910 00000000`73de8356 sqlncli10!XxMpHeapReAlloc+0xca 
04 00000000`1e29c950 00000000`73de82de sqlncli10!MpHeapReAlloc+0x44 
05 00000000`1e29c9e0 00000000`73de826e sqlncli10!MpReallocZeroMemory+0x69 
06 00000000`1e29ca10 00000000`73dfb015 sqlncli10!SQLReAllocateMemoryEx+0x2a 
07 00000000`1e29ca50 00000000`73df8b7b sqlncli10!PlAddNewIEx+0x8e 
08 00000000`1e29caa0 00000000`73df869b sqlncli10!SortErrors+0x6b 
09 00000000`1e29cae0 000007fe`f6448d44 sqlncli10!SQLGetDiagFieldW+0x2bc 
0a 00000000`1e29d180 000007fe`f64471b9 odbc32!DriverGetDiagField+0x124 
0b 00000000`1e29d200 00000000`743a253e odbc32!SQLGetDiagFieldW+0x471 
0c 00000000`1e29d750 00000000`7439d0d3 sqlsvc!GetInfoMessage+0x4e 
0d 00000000`1e29d7b0 00000000`7439fee2 sqlsvc!dbQSQLMessageHandler+0x3a3 
0e 00000000`1e2a1b50 00000000`0021c416 sqlsvc!QSQLExecDirectAsync+0x1a2 
0f 00000000`1e2a1bb0 00000000`0021bac7 SQLAGENT!DoSQL+0x316 
10 00000000`1e2a21a0 00000000`002339a3 SQLAGENT!ExecuteTSQL+0xd97 
11 00000000`1e2a6cd0 00000000`00231f8a SQLAGENT!StartStep+0x693 
12 00000000`1e2a77d0 00000000`00230daf SQLAGENT!DoStep+0x3ba 
13 00000000`1e2ac7a0 00000000`756437d7 SQLAGENT!JobManager+0xa6f

CAUSE

When you try to kill the session that is running the query, an internal exception occurs. SQL Server begins to iterate an indefinite loop. Therefore, you cannot kill the session, and the performance decreases.

RESOLUTION

Cumulative update information for SQL Server 2005 Service Pack 2

The fix for this issue was first released in Cumulative Update 12 for SQL Server 2005 Service Pack 2. For more information about this cumulative update package, click the following article number to view the article in the Microsoft Knowledge Base:
962970 Cumulative update package 12 for SQL Server 2005 Service Pack 2
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 fix release. Microsoft recommends that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
937137 The SQL Server 2005 builds that were released after SQL Server 2005 Service Pack 2 was released
Microsoft SQL Server 2005 hotfixes are created for specific SQL Server service packs. You must apply a SQL Server 2005 Service Pack 2 hotfix to an installation of SQL Server 2005 Service Pack 2. By default, any hotfix that is provided in a SQL Server service pack is included in the next SQL Server service pack.

Cumulative update information for SQL Server 2005 Service Pack 3

The fix for this issue was first released in Cumulative Update 3 for SQL Server 2005 Service Pack 3. For more information about how to obtain this cumulative update package for SQL Server 2005, click the following article number to view the article in the Microsoft Knowledge Base:
967909 Cumulative update package 3 for SQL Server 2005 Service Pack 3
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
960598 The SQL Server 2005 builds that were released after SQL Server 2005 Service Pack 3 was released

Cumulative update information for the release version of SQL Server 2008

The fix for this issue was first released in Cumulative Update 4. For more information about how to obtain this cumulative update package for SQL Server 2008, click the following article number to view the article in the Microsoft Knowledge Base:
963036 Cumulative update package 4 for SQL Server 2008
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
956909 The SQL Server 2008 builds that were released after SQL Server 2008 was released

Cumulative update information for SQL Server 2008 Service Pack 1

The fix for this issue was first released in Cumulative Update 1 for SQL Server 2008 Service Pack 1. For more information about how to obtain this cumulative update package for SQL Server 2008, click the following article number to view the article in the Microsoft Knowledge Base:
969099 Cumulative update package 1 for SQL Server 2008 Service Pack 1
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
970365 The SQL Server 2008 builds that were released after SQL Server 2008 Service Pack 1 was released

WORKAROUND

To work around symptom 1, use an expression for the SQLStatementSource property of the Execute SQL task to specify the SELECT statement by using the variable. For example, set the following expression for the SQLStatementSource property of the Execute SQL task.
SELECT filed1 AS a FROM table1 WHERE filed1="+ @[User::variable1]
For symptom 2, if SQLAgent unusually high memory growth is seen, the root cause of the OLEDB error should also be investigated and resolved as well as applying the cumulative update to the SQL Server process.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

More information about cumulative update package 12 for SQL Server 2005 Service Pack 2

For more information about what files are changed, and for information about any prerequisites to apply the cumulative update package that contains the hotfix that is described in this Microsoft Knowledge Base article, click the following article number to view the article in the Microsoft Knowledge Base:
962970 Cumulative update package 12 for SQL Server 2005 Service Pack 2

More information about cumulative update package 3 for SQL Server 2005 Service Pack 3

For more information about what files are changed, and for information about any prerequisites to apply the cumulative update package that contains the hotfix that is described in this Microsoft Knowledge Base article, click the following article number to view the article in the Microsoft Knowledge Base:
967909 Cumulative update package 3 for SQL Server 2005 Service Pack 3

More information about cumulative update package 4 for the release version of SQL Server 2008

For more information about what files are changed, and for information about any prerequisites to apply the cumulative update package that contains the hotfix that is described in this Microsoft Knowledge Base article, click the following article number to view the article in the Microsoft Knowledge Base:
963036 Cumulative update package 4 for SQL Server 2008

More information about cumulative update package 1 for SQL Server 2008 Service Pack 1

For more information about what files are changed, and for information about any prerequisites to apply the cumulative update package that contains the hotfix that is described in this Microsoft Knowledge Base article, click the following article number to view the article in the Microsoft Knowledge Base:
969099 Cumulative update package 1 for SQL Server 2008 Service Pack 1

Call stack information

0:053> kL30
Child-SP          Child-BSP         RetAddr           Call Site
00000000`46a3b320 00000000`46a41a78 00000000`77b99750 ntdll!RtlVirtualUnwind+0x100
00000000`46a3bc80 00000000`46a418f8 00000000`781a5900 ntdll!RtlUnwindEx+0x110
00000000`46a3c890 00000000`46a41870 00000000`781a2d40 msvcr80!_UnwindNestedFrames+0x2a0
00000000`46a3c970 00000000`46a41810 00000000`781a3950 msvcr80!CatchIt+0xe0
00000000`46a3c9d0 00000000`46a41730 00000000`781a41a0 msvcr80!FindHandler+0x710
00000000`46a3d480 00000000`46a416b8 00000000`781a4d90 msvcr80!__InternalCxxFrameHandler+0x4e0
00000000`46a3d480 00000000`46a41628 00000000`77c28860 msvcr80!__CxxFrameHandler3+0x370
00000000`46a3d4a0 00000000`46a41628 00000000`77b9a2d0 ntdll!RtlpExecuteEmHandlerForException+0x50
00000000`46a3d4c0 00000000`46a414a8 00000000`77b993a0 ntdll!RtlDispatchException+0x3f0
00000000`46a3e170 00000000`46a41450 00000000`77b99440 ntdll!RtlpRaiseException+0x120
00000000`46a3ec00 00000000`46a41438 00000000`76eb1d40 ntdll!RtlRaiseException+0x20
00000000`46a3ec00 00000000`46a413c8 00000000`781a5aa0 kernel32!GetDateFormatW+0x7a6d8
00000000`46a3eca0 00000000`46a41360 00000000`014f2d30 msvcr80!_CxxThrowException+0x160
00000000`46a3ecf0 00000000`46a412f0 00000000`014f3150 sqlservr!TurnUnwindAndThrowImpl+0x2f0
00000000`46a3ee50 00000000`46a411f0 00000000`014f37b0 sqlservr!ex_raise2+0x6b0
00000000`46a3f110 00000000`46a41190 00000000`038ee0e0 sqlservr!ex_raise+0xc0
00000000`46a3f150 00000000`46a41158 00000000`028bffa0 sqlservr!`anonymous namespace'::LogTdsProtocolError+0xd0
00000000`46a3f160 00000000`46a41138 00000000`0200eed0 sqlservr!`anonymous namespace'::RaiseErrorOnNestedStream+0x60
00000000`46a3f160 00000000`46a41088 00000000`01172180 sqlservr!CPostHydraTds::SendMsgImpl+0xe98100
00000000`46a3f1c0 00000000`46a41030 00000000`01172040 sqlservr!ODS_SENDFULLMSG+0x100
00000000`46a3f220 00000000`46a40fa0 00000000`011738b0 sqlservr!SendErrorToUser+0x1d0
00000000`46a3f290 00000000`46a40f20 00000000`01105a00 sqlservr!CErrorReportingManager::SendErrorToUser+0x260
00000000`46a3f320 00000000`46a40e10 00000000`0118a3d0 sqlservr!CErrorReportingManager::CwchFormatAndPrint+0x610
00000000`46a3f470 00000000`46a40dd8 00000000`0118a2f0 sqlservr!ex_vcallprint+0xb0
00000000`46a3f4b0 00000000`46a40d80 00000000`024cbfb0 sqlservr!ex_callprint+0xa0
00000000`46a3f4f0 00000000`46a40c90 00000000`02514e20 sqlservr!COledbError::FRelayErrorInfo+0x960
00000000`46a3f570 00000000`46a40c58 00000000`02f82030 sqlservr!COledbError::FPrintSQLServerError+0x190
00000000`46a3f5a0 00000000`46a40c10 00000000`0441b450 sqlservr!COledbError::GatherAndPrintMultipleResultsError+0x30
00000000`46a3f5b0 00000000`46a40b28 00000000`0164d160 sqlservr!CQScanRmtQueryNew::GetRow+0xad0
00000000`46a3f660 00000000`46a40a28 00000000`01768560 sqlservr!CQScanNLJoinTrivialNew::GetRow+0x1a90
00000000`46a3f690 00000000`46a40928 00000000`01333d30 sqlservr!CXStmtQuery::ErsqExecuteQuery+0xe50
00000000`46a3f760 00000000`46a407c8 00000000`0130ce40 sqlservr!CMsqlExecContext::ExecuteStmts<1,1>+0x19d0
00000000`46a3f870 00000000`46a406d0 00000000`0130ac70 sqlservr!CMsqlExecContext::FExecute+0x7c0
00000000`46a3f960 00000000`46a405f0 00000000`010fa300 sqlservr!CSQLSource::Execute+0x5f0
00000000`46a3fa10 00000000`46a404f8 00000000`010fa5c0 sqlservr!process_request+0x5c0
00000000`46a3fbe0 00000000`46a40478 00000000`0100e4b0 sqlservr!process_commands+0x6d0
00000000`46a3fdf0 00000000`46a40420 00000000`0100e210 sqlservr!SOS_Task::Param::Execute+0x1a0
00000000`46a3fe70 00000000`46a40378 00000000`0100dc30 sqlservr!SOS_Scheduler::RunTask+0x190
00000000`46a3fe90 00000000`46a402b0 00000000`01061ea0 sqlservr!SOS_Scheduler::ProcessTasks+0x170

REFERENCES

For more information about the list of builds that are available after SQL Server 2005 Service Pack 3, click the following article number to view the article in the Microsoft Knowledge Base:
960598 The SQL Server 2005 builds that were released after SQL Server 2005 Service Pack 3 was released
For more information about the list of builds that are available after the release of SQL Server 2008 Service Pack 1, click the following article number to view the article in the Microsoft Knowledge Base:
970365 The SQL Server 2008 builds that were released after SQL Server 2008 Service Pack 1 was released
For more information about the list of builds that are available after the release of SQL Server 2008, click the following article number to view the article in the Microsoft Knowledge Base:
956909 The SQL Server 2008 builds that were released after SQL Server 2008 was released
For more information about the list of builds that are available after SQL Server Service Pack 2, click the following article number to view the article in the Microsoft Knowledge Base:
937137 The SQL Server 2005 builds that were released after SQL Server 2005 Service Pack 2 was released
For more information about the Incremental Servicing Model for SQL Server, click the following article number to view the article in the Microsoft Knowledge Base:
935897 An Incremental Servicing Model is available from the SQL Server team to deliver hotfixes for reported problems
For more information about how to obtain SQL Server 2005 Service Pack 2, click the following article number to view the article in the Microsoft Knowledge Base:
913089 How to obtain the latest service pack for SQL Server 2005
For more information about the new features and the improvements in SQL Server 2005 Service Pack 2, visit the following Microsoft Web site:
http://go.microsoft.com/fwlink/?LinkId=71711
For more information about the naming schema for SQL Server updates, click the following article number to view the article in the Microsoft Knowledge Base:
822499 New naming schema for Microsoft SQL Server software update packages
For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates

Properties

Article ID: 961237 - Last Review: May 13, 2010 - Revision: 6.0
APPLIES TO
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Standard X64 Edition
  • Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Enterprise X64 Edition
  • Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Workgroup Edition
  • Microsoft SQL Server 2008 Workgroup
  • Microsoft SQL Server 2008 Web
  • Microsoft SQL Server 2008 Standard
  • Microsoft SQL Server 2008 Enterprise
Keywords: 
kbsql2005engine kbsurveynew kbexpertiseadvanced kbqfe kbfix KB961237

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com