HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Automated SP_WhoIsActive SQL Activity Capturing Issue

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
capturingsp_whoisactivesqlissueautomatedactivity

Problem

I have an SQL Agent Job on a production server that keeps failing with the below messages. It is supposed to be capturing SQL Server activity using the SP_WHOISACTIVE stored proc, at regularly scheduled intervals.


Executed as user: Warning: Null value is eliminated by an aggregate
or other SET operation. [SQLSTATE 01003] (Message 8153)


Warning: Null value is eliminated by an aggregate or other SET
operation. [SQLSTATE 01003] (Message 8153)


Warning: Null value is eliminated by an aggregate or other SET
operation. [SQLSTATE 01003] (Message 8153)


Violation of PRIMARY KEY constraint 'PK_WhoIsActive'. Cannot insert
duplicate key in object 'monitoring.WhoIsActive'. The duplicate key
value is (Jan 20 2017 8:25AM, 109). [SQLSTATE 23000] (Error 2627)


The statement has been terminated. [SQLSTATE 01000] (Error 3621).


The step failed.

Any idea what may be causing this?

What steps should I follow to fix this error?

Solution

It appears from the Primary Key name that you are running Adam Machanic's sp_WhoIsActive and storing the result in a table.

If that is the case, the warnings are normal and caused by the options you set when calling sp_WhoIsActive. The Primary Key violation is what is causing the job to fail.
Take a look at the definition of the primary key.

I believe you will find that the Primay Key needs to be changed in order to insure uniqueness.

In my implementations for this I leave the table as a heap and do not define a primary key on this table. I only keep a few days of data in the table and do not use it for replication.

Here is an article on how to implement it:
Brent Ozar Implementation of sp_WhoIsActive

Context

StackExchange Database Administrators Q#161752, answer score: 5

Revisions (0)

No revisions yet.