Working folders, logs and sessions for sp_execute_external_script

[This article was first published on R – TomazTsql, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

When running with R code and sp_execute_external_script it is very handy to know where all the output log files are being generated and what additional information about the session is available and which folders are useful when working with external stored procedure sp_execute_external_script.

Session information is stored on your local disk under location:

C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER\MSSQL\ExtensibilityData

with subfolders: \SQLSERVER01\2EDE2133-E0A1-42A9-8F1E-958E87AB92B5

2016-07-20 19_51_10-SQLSERVER2016RC301

These folders consist of subfolders and files of sessions ID. Nature of this folders is that they are purged after the session is closed – it can be from 6 to n-minutes. On my client I have by default 6 minutes. After this time, the sessions are closed and if you rerun the sp_execute_external_script from SSMS you will notify a slight delay because the R engine needs to re-establish all the sessions again in comparison of running the same script one time after another time.

The session file includes following RevoScaleR code:

library(RevoScaleR); 
sessionDirectory <- 'C:\\PROGRA~1\\MICROS~2\\MSSQL1~1.SQL\\MSSQL\\EXTENS~1\\SQLSERVER01\\C13E33C2-A71D-4ED3-AA13-B79BB2A1FBC1';
sessionId <- 'C13E33C2-A71D-4ED3-AA13-B79BB2A1FBC1';
scriptFile <- file.path(sessionDirectory, paste(sessionId, '.R', sep=''));
rxIgnoreCallResult <- .Call('RxSqlSessionStart', list(sessionDirectory=sessionDirectory, sessionId=sessionId, waitTime=-1));
source(scriptFile)

 

Those who wanted to capture the output and log file that R engine usually generates. With sp_execute_external_script these files can not be navigated to, since procedure is a CLR and using preassigned assembly, even though the script is sent to R engine using CMD batch. This peace of information can be found on in file: C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER\MSSQL\Binn\rlauncher.config and for my configuration the content is as following:

RHOME=C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER\R_SERVICES
MPI_HOME=C:\Program Files\Microsoft MPI
INSTANCE_NAME=SQLSERVER
TRACE_LEVEL=1
JOB_CLEANUP_ON_EXIT=1
USER_POOL_SIZE=0
WORKING_DIRECTORY=C:\PROGRA~1\MICROS~2\MSSQL1~1.SQL\MSSQL\EXTENS~1

These are all the global settings for R engine that is ran from SQL Server 2016 engine. And assembly to support R engine is located:

C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER\MSSQL\Binn\RLauncher.dll.

which is also the name of the service:

2016-07-20 20_39_01-Services

 

And finally, by running:

exec sp_helpextendedproc sp_execute_external_script

With this procedure one can find out that sp_execute_external_script is presented as dll.

2016-07-20 20_55_14-roles_security_sp_execute_external_Script.sql - SICN-00031_SQLSERVER2016RC3.mast

Happy T-SQLRing!:-)

 

*Blog post might change due to new/better information regarding this topic! This will be marked in accordance.


To leave a comment for the author, please follow the link and comment on their blog: R – TomazTsql.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)