Data function fails to execute with the error: "Could not execute function call. TIBCO Spotfire Statistics Services did not return a response. See the debug log for further information."

Data function fails to execute with the error: "Could not execute function call. TIBCO Spotfire Statistics Services did not return a response. See the debug log for further information."

book

Article ID: KB0080222

calendar_today

Updated On:

Products Versions
Spotfire Statistics Services All supported versions

Description

When attempting to execute a data function in the installed Spotfire desktop client which is executed on an external TIBCO Spotfire Statistics Services server, the data function fails and the following error is reported in the status bar:

Could not execute function call. TIBCO Spotfire Statistics Services did not return a response. See the debug log for further information.
 

On the TIBCO Spotfire Statistics Services server in the "SplusServer.log" file, the following error is seen:

2016-05-03 13:28:27,267 | ERROR |  | JobExecutionPoolThread | JobExecutionThreadPool-1: Error while executing the Runnable:
java.lang.IllegalStateException: execution failed jobId:316
    at com.insightful.splusserver.threadpool.ScheduledJobExecutor.execute(ScheduledJobExecutor.java:89)
    at com.insightful.splusserver.threadpool.JobExecutionPoolThread.run(JobExecutionPoolThread.java:132)
    ....
    Caused by: org.h2.jdbc.JdbcSQLException: Value too long for column "WARNINGS VARCHAR(65535)": "'{""warnings"":[""`[<-.data.frame`(`*tmp*`, , indexed, value = list(2.1, 2.1, 2.1,  : provided 104 variables to replace 1 variables... (67207)"; SQL statement:
    update SPLUS_JOBS set VERSION = ?,STATUS = ?,JOB_TYPE = ?,SERVER_INSTANCE = ?,NOTIFICATION_REQUES

 

Issue/Introduction

Data function fails to execute with the error: "Could not execute function call. TIBCO Spotfire Statistics Services did not return a response. See the debug log for further information." In the SplusServer.log file, the "Value too long for column "WARNINGS VARCHAR(65535)"" is seen.

Environment

All supported environments

Resolution

This will be seen when execution of a data function's script leads to more than 65535 characters of warning messages. This is beyond the maximum character count allowed for the WARNINGS column in the TIBCO Spotfire Statistics Services server application database, which stores the job execution history. The job execution fails because TIBCO Spotfire Statistics Services does not currently truncate warnings.

You can avoid this issue by rewriting the data function's script to reduce the number (and length) of warnings generated in its execution.

It is also possible to suppress the return of warnings generated in the script.  Available options for doing this include the following:

Option 1:

Wrap the entire problematic script in a call to the function provided below, suppressTrailingWarnings(), which will suppress all but the first 'nWarningsToSignal' warnings.


suppressTrailingWarnings <- function(expr, nWarningsToSignal = 5)
{
    nWarnings <- 0
    on.exit(
        if (nWarnings >= nWarningsToSignal) {
            warning("Only the first ", nWarningsToSignal - 1, " of ", nWarnings, " warnings were reported")
        }
    )
    withCallingHandlers(
        expr,
        warning=function(w){
            nWarnings <<- nWarnings + 1
            if (nWarnings < nWarningsToSignal) {
                warning(w)
            }
            invokeRestart("muffleWarning")
        }
    )
}


Since this function is not defined in a package, you need to define it in the data function script. 

For example, assume your failing script is:


fit <- lm(Y ~ X1 + X2, data = DATA)
RESIDUALS <- residuals(fit)
FITTEDVALUES <- fitted(fit)


Define the suppressTrailingWarnings() function and then wrap the problematic function in it, like this:

suppressTrailingWarnings <- function(expr, nWarningsToSignal = 5)
{
    nWarnings <- 0
    on.exit(
        if (nWarnings >= nWarningsToSignal) {
            warning("Only the first ", nWarningsToSignal - 1, " of ", nWarnings, " warnings were reported")
        }
    )
    withCallingHandlers(
        expr,
        warning=function(w){
            nWarnings <<- nWarnings + 1
            if (nWarnings < nWarningsToSignal) {
                warning(w)
            }
            invokeRestart("muffleWarning")
        }
    )
}
suppressTrailingWarnings({
    fit <- lm(Y ~ X1 + X2, data = DATA)
    RESIDUALS <- residuals(fit)
    FITTEDVALUES <- fitted(fit)
}, nWarningsToSignal = 3) # default is 5



That function should emit at most 'nWarningsToSignal' warnings (including a possible trailing warning that says how many were not reported). For example:

> funkyFunction <- function(i) if (i<0) warning(i, " is negative")

> suppressTrailingWarnings(for(i in 5:-3) funkyFunction(i))
Warning messages:
1: In funkyFunction(i) : -1 is negative
2: In funkyFunction(i) : -2 is negative
3: In funkyFunction(i) : -3 is negative
>
> suppressTrailingWarnings(for(i in 5:-300) funkyFunction(i))
Warning messages:
1: In funkyFunction(i) : -1 is negative
2: In funkyFunction(i) : -2 is negative
3: In funkyFunction(i) : -3 is negative
4: In funkyFunction(i) : -4 is negative
5: In suppressTrailingWarnings(for(i in 5:-300) funkyFunction(i)) : Only the first 4 of 300 warnings were reported


Option 2:

For single statements, you can use the suppressWarnings() function, but this is inefficient for more complex data functions:


suppressWarnings( expr )

Option 3:

You can disable warnings globally with the options() function, but it is not optimal to completely disable warnings:


options( warn = -1 )


Disclaimer:
The code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the code in accordance with your implementation specifications that best suit your business requirements. Refer to the reference(s) cited in this article for usage of the functions and methods used in the code.