How to fix error recording sp_whoisactive results to table?
You will have to download a newer version of Adam Machanic's sp_whoisactive stored procedure.
Preferably 11.16 or newer:

Version 11.16 - October 18, 2016 (Box versions 2005-2017 only. NOT for Azure PAAS.)

Fixed algorithm for identifying &quot;special&quot; database pages (e.g. GAM, SGAM). Thanks, Robert Davis!
Fixed @blockers duplicate key bug


In the code the definition of the @blockers table variable was changed to:
...
DECLARE @blockers TABLE
(
session_id INT NOT NULL PRIMARY KEY WITH (IGNORE_DUP_KEY = ON) /*&lt;&lt;== HERE!*/
);
...

And then again, you could modify your existing code.