When we run this on our SQL Server 2008 R2 instances, it causes a severity 20 error every time. It does not have that issue on our SQL Server 2016 instances.
Query:
DECLARE @v varchar(MAX) = REPLICATE(CONVERT(varchar(max),'a'),524289);
SELECT @v = @v FROM(SELECT 1 AS a) AS b;
Result:
Location: tmpilb.cpp:3256
Expression: fNoReaderWriterConflict
SPID: 90
Process ID: 1576
Location: tmpilb.cpp:3306
Expression: fNoReaderWriterConflict
SPID: 90
Process ID: 1576
Msg 3624, Level 20, State 1, Line 4
A system assertion check has failed. Check the SQL Server error log for details. Typically, an assertion failure is caused by a software bug or data corruption. To check for database corruption, consider running DBCC CHECKDB. If you agreed to send dumps to Microsoft during setup, a mini dump will be sent to Microsoft. An update might be available from Microsoft in the latest Service Pack or in a QFE from Technical Support.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
SELECT @@VERSION
:
Microsoft SQL Server 2008 R2 (SP3) - 10.50.6000.34 (X64)
Aug 19 2014 12:21:34
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
SQLDump0002.txt (from non-production server):
Computer type is Intel(R) Xeon(R) CPU E5430 @ 2.66GHz.
Bios Version is DELL - 1
Phoenix ROM BIOS PLUS Version 1.10 2.5.0
8 X64 level 8664, 2 Mhz processor (s).
Windows NT 6.1 Build 7601 CSD Service Pack 1.
Memory
MemoryLoad = 87%
Total Physical = 32762 MB
Available Physical = 4058 MB
Total Page File = 65524 MB
Available Page File = 27332 MB
Total Virtual = 8388607 MB
Available Virtual = 8355194 MB
**Dump thread - spid = 0, EC = 0x00000003EF7E5F00
Is this a bug in this version of SQL Server 2008 R2?
Updates:
- This does produce a set of crash dump related files. The layperson-readable sections of them basically repeat the error result above.
- We recognize SQL Server 2008 R2 is old and out of support. We will be upgrading.
- We have already worked around this issue by setting the large text variable outside of a SELECT statement.
- We were curious if this happened in any other environments and we wanted this publicly documented in case it happens to someone else.