SQL Server A weirdly selective "No process is on the other end of the pipe" error in "bpctxt.cpp" only in sql procedure

lfapxunr  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(97)

I get this error when I try to run a SQL procedure:

Location:    "bpctxt.cpp":129
Expression:  m_cCreated < m_cMaxBatches
SPID:        63
Process ID:  820
Msg 233, Level 20, State 0, Line 0
A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

The weird thing is, the query works perfectly well when I run it as-is, with the same parameters, but outside of the procedure.

The procedure is created and runs on database A. It accesses databases B or C (which are similar in structure and located on the same server), depending on a set of conditions. The procedure runs fine if database B is hit, even inside the procedure. It's only when database C is accessed that I run into this error.

I also have other procedures accessing that problematic database (and some of the same tables) which run fine, too.

My problematic procedure is very simple and looks something like this (pseudo-code for simplicity):

CREATE PROCEDURE [dbo].[GetData] 
@switchCondition NVARCHAR(20)
AS 
BEGIN
   IF @switchCondition = 'X'
   select <<set of columns>> from databaseB.<<set of tables & views>> -- this works fine
   ELSE 
   select <<set of columns>> from databaseC.<<set of tables & views>> -- this causes the error
END;

If I run the code in MSSQL Management Studio directly, like this:

DECLARE @switchCondition nvarchar(20)='Y';
IF @switchCondition = 'X'
select <<set of columns>> from databaseB.dbo.<<set of tables & views>> -- this works fine
ELSE 
select <<set of columns>> from databaseC.dbo.<<set of tables & views>> -- here this also doesn't cause the error

everything runs fine, and the correct results are returned.

The error is the same no matter if I'm using the sa account or the Windows account.

I have run DBCC CheckDB and it returns no errors. I connected and disconnected. I restarted the server. I've run sp_refreshsqlmodule , rebuilt the indexes, and updated the statistics. The error persists.

What could be causing this?

uelo1irk

uelo1irk1#

One can only guess without the actual queries and the SQL Server version. Googling for bpctxt.cpp returns a SQL Server 2019 fix for a bug in some windowing queries.

The fix description matches the question's error:
Fixes an assertion failure (Location: bpctxt.cpp:129; Expression: 'm_cCreated < m_cMaxBatches') that you encounter when running window queries that have aggregate functions in batch mode.

Without more information I'd guess the queries use both aggregations and windowing, the server is SQL Server 2019 and CU 20 hasn't been applied yet. The solution is to either install a recent CU, or simplify the query.

Without the queries themselves it's not possible to say how they can be simplified

相关问题