Having seemingly brought down our 9.2 Windows 2008 STP server (only in DEV!!) during development of a yet another (awesome) STP web app, it occurred to me that more information was needed about just how many requests were being batted over.
Unable to execute stored process.
The server is not running (paused/deferred stop mode?).
So, inspired by Quentin McMullen’s excellent post, I wanted to share my approach.
Step 1 was to create a table to log the events. This was structured as follows:
CREATE TABLE [dbo].[STP_LOGGER](
[PROCESSED_DTTM] datetime2 NOT NULL,
[STATUS_CD] char NOT NULL,
[_PROGRAM] [char] (500) NOT NULL,
[_METAPERSON] [char] (100) NOT NULL,
[SYSJOBID] [char] (12) NOT NULL,
[_SESSIONID] [char] (50) NULL,
[GLOB_VARS] [char] (2000) NULL
Note that this table was not a SAS table (which could be subject to locking). If you have no other choice but to use a SAS table, please refer to the previous post for attempting SAS locks (noting that this can not be done via the meta engine).
Step 2 was to create a macro to update the table (to be placed somewhere in SASAUTOS). Example below:
%macro stplogger(statuscd= );
proc sql noprint;
separated by ’|’
where scope = ‘GLOBAL’
and substr(name,1,3) not in(‘SYS’, ‘SQL’,‘SAS’)
and substr(name,1,1) ne ’‘;
proc datasets library=work; delete append; run;
data append /view=append;
if 0 then set web.stplogger;
%if not %symexist(_SESSIONID) %then %do;
/ session id is stored in the replay variable but needs to be extracted /
if index=-1 then index=length(_replay);
drop _replay index;
/_ explicitly created sessions are automatically available /
proc append base=web.stplogger data=append;run;
proc sql; drop view append;
Step 3 was to call the macro. The quick / dirty way would be to simply include it in the SAS programs directly, but that quickly becomes unmanageable when dealing with a large number of STPs. Another option is to include in the autoexec, but that will only deal with program ENTRY (not exit).
The best approach, as endorsed by Don Henderson, is to use the STP init and term programs. These are straightforward .sas programs that run on an STP session’s entry and exit. Configuration is simple, and explained here: https://support.sas.com/kb/39/250.html. This approach is fantastic as it will ensure that ALL calls to the STP server are logged (eg via EG, AMO, WRS, every custom web app, etc etc). Simply add the following one-liners to each file:
%stplogger(statuscd=SrvEnter) /_ goes in the init file /
%stplogger(statuscd=SrvExit) / goes in the term file _/
Boom, we are done, and here is an extract of the new logging table:
See that highlighted row? A hung session with my name against it…
EDIT 13OCT2015: The connection issue was finally resolved by setting the Recycle Activation Limit to 1. This had no noticeable effect on performance.