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](3) NOT NULL,
[STATUS_CD] [char](8) 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).
%macro stp_logger(status_cd= );
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.stp_logger;
%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.stp_logger 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: http://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:
%stp_logger(status_cd=SrvEnter) /* goes in the init file */
%stp_logger(status_cd=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.