Microsoft KB Archive/912885

= FIX: You may receive an access violation error message when you run a parallel execution plan in SQL Server 2005 =

Article ID: 912885

Article Last Modified on 11/20/2007

-

APPLIES TO


 * Microsoft SQL Server 2005 Enterprise Edition
 * Microsoft SQL Server 2005 Enterprise X64 Edition
 * Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems
 * Microsoft SQL Server 2005 Developer Edition
 * Microsoft SQL Server 2005 Standard Edition
 * Microsoft SQL Server 2005 Standard X64 Edition
 * Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems Community Technology Preview

-



BUG #: 420246 (SQLBUDT)



Microsoft distributes Microsoft SQL Server 2005 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 fix release.



SUMMARY
This article describes the following about this hotfix release:
 * The issues that are fixed by the hotfix package
 * The prerequisites for installing the hotfix package
 * Whether you must restart the computer after you install the hotfix package
 * Whether the hotfix package is replaced by any other hotfix package
 * Whether you must make any registry changes
 * The files that are contained in the hotfix package



SYMPTOMS
In Microsoft SQL Server 2005, you may receive an access violation error message when the following conditions are true:
 * You create an index that uses the IGNORE_DUP_KEY option for a table.
 * You run an INSERT statement that inserts a new row into this index.
 * The plan for the INSERT statement is parallel.
 * The value for one of the key columns of the IGNORE_DUP_KEY option is provided by using a parameter.

Additionally, you may receive an error message that is similar to the following:

A server error occurred on the current command. The results, if any, should be discarded.



Hotfix information
A supported hotfix is now available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next service pack that contains this hotfix.

To resolve this problem, submit a request to Microsoft Online Customer Services to obtain the hotfix. To submit an online request to obtain the hotfix, visit the following Microsoft Web site:

http://go.microsoft.com/?linkid=6294451

Note If additional issues occur or any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. To create a separate service request, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Prerequisites
There are no prerequisites for this hotfix.

Restart information
You do not have to restart the computer after you apply this hotfix.

Registry information
You do not have to change the registry.

File information
This hotfix contains only those files that are required to correct the issues that this article lists. This hotfix may not contain all the files that you must have to fully update a product to the latest build.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

SQL Server 2005 for Itanium-based systems


WORKAROUND
To work around this problem, follow these steps:
 * 1) Determine the problematic INSERT statement that causes the access violation.
 * 2) Force the query optimizer to generate a serial plan for the problematic INSERT statement. Therefore, the statement can be executed on one thread.

Note If you cannot determine the problematic INSERT statement that causes the access violation, you can use the method that is described in Method 3 to work around this problem.

To determine the problematic INSERT statement that causes the access violation, follow these steps:  In the SQL Server error log file, locate the access violation error message. Near the top of the access violation error message, locate the input buffer information. Locate the batch information that follows the input buffer information.

Note The batch contains the problematic INSERT statement that causes the access violation. If the batch contains only one INSERT statement, this statement is exactly the problematic INSERT statement. If the batch contains multiple INSERT statements, perform the follow operations to determine the problematic INSERT statement:  In SQL Server Profiler, create a trace against the instance of SQL Server 2005.</li> In the Errors and Warnings event category, select the Attention event class and the Exception event class.

Note You can use these event classes to determine the last statement that begins to run before the access violation occurs.

If the batch contains only Transact-SQL statements, select the following additional event classes under the TSQL event category: <ul> SQL:BatchStarting</li> SQL:BatchCompleted</li> SQL:StmtStarting</li> SQL:StmtCompleted</li></ul>

If the batch contains a stored procedure in which the access violation occurs, select the following additional event classes under the Stored Procedures event category: <ul> SP:Starting</li> SP:Completed</li> SP:StmtStarting</li> SP:StmtCompleted</li></ul> </li> Run the same batch from the client application.

You follow this step to reproduce the access violation. Then, you can determine the problematic INSERT statement. When you run the batch, make sure that the trace is running.

If the client application is not SQL Server Management Studio, you may also manually run the same batch in SQL Server Management Studio. However, you may not obtain the same execution plan as the original execution plan that causes the problem. This behavior occurs if SQL Server 2005 recompiles the problematic INSERT statement in the batch by using a different execution plan or by using different parameters.</li> Stop the trace, and then analyze the trace results to determine the problematic INSERT statement. To determine the problematic INSERT statement, determine the SPID that experiences the access violation and that disconnects the client application. Then, on the SPID, notice the INSERT statement that meets the following requirements: <ul> The INSERT statement is started.</li> The same INSERT statement is not completed.</li></ul> </li></ol> </li></ol>

To force the query optimizer to generate a serial plan for the problematic INSERT statement, use one of the following methods.

Method 1
Note Use this method if you can access the problematic INSERT statement.

Add the OPTION (MAXDOP 1) expression to the problematic INSERT statement. The following is an example of the new INSERT statement. INSERT INTO MyTable (Col1, Col2) SELECT Col1, Col2 FROM OtherTable OPTION (MAXDOP 1) For more information about the MAXDOP query hint, see the &quot;Using MAXDOP&quot; section on the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/ms181714.aspx

Method 2
Note Use this method if you cannot access the problematic INSERT statement. For example, the problematic INSERT statement is from a client application. However, you cannot reconfigure the client application or you cannot recompile the client application to add the OPTION (MAXDOP 1) expression. Or, the problematic INSERT statement is in a stored procedure. However, the stored procedure is encrypted. You cannot change the statements in the stored procedure.

Use the sp_create_plan_guide stored procedure against the problematic INSERT statement. By doing this, you force the OPTION (MAXDOP 1) expression on the problematic INSERT statement. The following is an example of how to use the sp_create_plan_guide stored procedure. sp_create_plan_guide @name = N'planguide_for_MyFailingProc', -- Arbitrary name @stmt = N'INSERT INTO MyOneFailingStatementTable VALUES (@a,@b,@c)', -- The problematic INSERT statement @type = N'OBJECT', @module_or_batch = N'dbo.MyFailingProc', -- The name of the stored procedure that contains the problematic INSERT statement @params = NULL, @hints = N'OPTION (MAXDOP 1)'-- Query hint to prevent parallelism For more information about the sp_create_plan_guide stored procedure, visit the following MSDN Web site:

http://msdn2.microsoft.com/en-us/library/ms179880.aspx

Method 3
Note Use this method if one of the following conditions is true:
 * The problematic INSERT statement is dynamically generated.
 * You cannot determine the INSERT statement that causes the access violation.

Important This method enables all queries on the instance of SQL Server 2005 to run on one thread. We do not suggest that you use this method. This method may cause performance issues on the other queries that run on the instance.

Run the following Transact-SQL statements. sp_configure 'show advanced options', 1; GO

RECONFIGURE WITH OVERRIDE; GO

sp_configure 'max degree of parallelism', 1; GO

RECONFIGURE WITH OVERRIDE; GO For more information about the max degree of parallelism option, visit the following MSDN Web site:

http://msdn2.microsoft.com/en-us/library/ms181007.aspx

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_section">

MORE INFORMATION
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

Keywords: kbbug kbfix kbqfe kbpubtypekc kbsqlserv2005fix kbhotfixserver kbsql2005engine kbsql2005presp1fix KB912885

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.