rstudio / promises

A promise library for R
https://rstudio.github.io/promises
Other
197 stars 19 forks source link

Warning: Error in unserialize: MultisessionFuture (<none>) failed to receive results from cluster RichSOCKnode #1 (PID 235 on ‘localhost’). #77

Closed can-taslicukur closed 2 years ago

can-taslicukur commented 2 years ago

Hi i am using promises with future in my shiny app to make async queries to MySQL database. This is the code that i use to send asynchronous query to database

library(promises)
library(future)
plan(multisession)

dat <- future_promise({
    con <- dbConnect(MySQL(),
                     user = DB_USER, password = DB_PASSWORD,
                     host = DB_HOST, port = DB_PORT,
                     dbname = DB_NAME, encoding = "latin1")
    dbSendQuery(con, "SET NAMES utf8mb4;")
    dbSendQuery(con, "SET CHARACTER SET utf8mb4;")
    dbSendQuery(con, "SET character_set_connection=utf8mb4;")
    dat <- dbGetQuery(con,query$df_sql)
    dbDisconnect(con)
    return(dat)
})

### after some time
dat

However when i run this code, I randomly get the following error

Warning: Error in unserialize: MultisessionFuture (<none>) failed to receive results from cluster RichSOCKnode #1 (PID 235 on ‘localhost’). The reason reported was ‘error reading from connection’. Post-mortem diagnostic: The total size of the 6 globals exported is 74.26 KiB. The three largest globals are ‘query’ (18.91 KiB of class ‘list’) and ‘dbSendQuery’ (10.30 KiB of class ‘function’)

Why do I get this error at random (not all the time)? Sometimes it works exactly like I wanted but sometimes i get this weird error. How can i fix it?

Session Info:

R version 4.1.1 (2021-08-10)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.0.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.1.1 DBI_1.1.1      tools_4.1.1   
HenrikBengtsson commented 2 years ago

I think this can be closed; there's an active discussion on https://github.com/HenrikBengtsson/future/discussions/570 about this problem.

PS. @can-taslicukur, please avoid cross posting the same question to multiple places to spare the brain cycles and efforts of devs and others, e.g. someone here might try to reproduce your error right now without knowing about our discussion over in the future forum.

can-taslicukur commented 2 years ago

Yes, I couldnt decide which package was the problem so i posted to both repos. I apologize for that