Skip to content

Commit 0bd3106

Browse files
authored
Merge pull request #3297 from mbambion/Issue_3291_mbambion
#3291 FIX: sp_BlitzCache fails when executed on instances with readable secondary replicas
2 parents e13b504 + 91f4d92 commit 0bd3106

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

sp_BlitzCache.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,7 @@ BEGIN
15791579
RAISERROR('Checking for Read intent databases to exclude',0,0) WITH NOWAIT;
15801580

15811581
EXEC('INSERT INTO #ReadableDBs (database_id) SELECT DBs.database_id FROM sys.databases DBs INNER JOIN sys.availability_replicas Replicas ON DBs.replica_id = Replicas.replica_id WHERE replica_server_name NOT IN (SELECT DISTINCT primary_replica FROM sys.dm_hadr_availability_group_states States) AND Replicas.secondary_role_allow_connections_desc = ''READ_ONLY'' AND replica_server_name = @@SERVERNAME OPTION (RECOMPILE);');
1582+
EXEC('INSERT INTO #ReadableDBs VALUES (32767) ;'); -- Exclude internal resource database as well
15821583
END
15831584

15841585
RAISERROR(N'Checking plan cache age', 0, 1) WITH NOWAIT;

0 commit comments

Comments
 (0)