The postings on this site are my own and do not represent my Employer's positions, advice or strategies.

LifeAsBob - Blog

 

Home

No Ads ever, except search!
Friday, April 19, 2024 Login
Public

query sysprocesses fails for read_only availability group 12/29/2014 3:51:56 PM

We have a process that queries sysprocesses (or sys.processes) and tracks some information.

Recently it began failing on a read_only node of an always-on availability group.  We have several other servers configured the exact same way and it does not happen.  We are unable to determine why this server has this behavior, no other errors or issues have been found.  We did find a cumbersome work-around, listed below.  SQL Server 2012, 10.0.5500.

select * from sysprocesses

select * from sys.sysprocesses

Msg 978, Level 14, State 1, Line 1

The target database ('Some_database') is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online.

-- now run from linked server, which has a loop back to the server itself with applicationintent=readonly

/* this code will drop and create the linked server

IF EXISTS (select * from master..sysservers where srvname = 'LOCALSERVER') EXEC master.dbo.sp_dropserver @server=N'LOCALSERVER', @droplogins='droplogins'

EXEC master.dbo.sp_addlinkedserver @server = N'LOCALSERVER', @srvproduct=N'', @provider=N'SQLNCLI11', @datasrc=@@servername, @provstr=N'APPLICATIONINTENT=READONLY'

*/

select * from openquery (LOCALSERVER, 'select * from sysprocesses')


Blog Home