SQL 2019 Parallel R Script calling rxExec Hangs

Copper Contributor

When calling the Attached R Script utilizing the rxExec function on SQL Server 2019 RTM, the script hangs and does not complete execution.  The same script succeeds on SQL Server 2016 CU11.

 

Is there a breaking change to rxExec for SQL Server 2019?  If so what is the preferred way to work around this issue.


--Server 1 1 Socket 6 cores SQL Server 2019 Process Hangs
--Server 2 4 Sockets 4 cores $numCoresToUse = 4 SQL Server 2016 Execution Time 00:33

DECLARE @rscript nvarchar(max)
SET @rscript = N'
playDice <- function()
{
Sys.sleep(1)
result <- NULL
point <- NULL
count <- 1
while (is.null(result))
{
roll <- sum(sample(6, 2, replace=TRUE))
if (is.null(point))
{
point <- roll
}
if (count == 1 && (roll == 7 || roll == 11))
{
result <- "Win"
}
else if (count == 1 && (roll == 2 || roll == 3 || roll == 12))
{
result <- "Loss"
}
else if (count > 1 && roll == 7 )
{
result <- "Loss"
}
else if (count > 1 && point == roll)
{
result <- "Win"
}
else
{
count <- count + 1
}
}
result
}

rxSetComputeContext(RxLocalParallel())

print(rxOptions())
z <- rxExec(playDice, timesToRun=100)

#library(doParallel)
#cl <- makeCluster(detectCores())
#print(detectCores())
#registerDoParallel(cl)

#z <- foreach(i=1:100) %dopar% playDice()

#stopCluster(cl)

ResultDf <- data.frame(matrix(unlist(z), nrow=length(z), byrow=T))
'
EXECUTE sp_execute_external_script
@language = N'R'
,@script = @rscript
,@parallel = 0
,@output_data_1_name = N'ResultDf'



 

0 Replies