RMySQL
RMySQL copied to clipboard
RMySQL connection without handle Error
I am running RMySQL version 0.10.8 and seeing the Error in .local: internal error in RS_DBI_getConnection: corrupt connection handle
- when trying to run the shiny app. The MySQL query is being run from server.R
This needs a bit more detail, but could be a duplicate of https://github.com/rstats-db/DBI/issues/101. What DBI version are you using?
More details are here. http://stackoverflow.com/questions/37035304/regex-query-from-shiny-server-to-mysql
DBI_0.4
Does the error also occur with DBI 0.3.1? If not, I'd suggest to stick with that until I release a new DBI version.
Hey, I think I'm having this same problem, also using RMySQL and Shiny. Packages: RMySQL_0.10.9 shiny_0.14.2 DBI_0.5-1
I make a connection like this;
con <- dbConnect(MySQL(), group="local", db="mydb")
Then I do the normal stuff; dbGetQuery, dbSendQuery, + sqlInterpolate
And at the end of my server function I have:
cancel.onSessionEnded <- session$onSessionEnded(function() { dbDisconnect(con) })
It'll work for a while, then on reload it'll stop working. I have multiple people using the same app across different machines, and after a while we get this same error as issue-starter:
Error in .local: internal error in RS_DBI_getConnection: corrupt connection handle
Previously I've tried killing all connections when the app starts up, but I'm not sure if that fixes this error or if that is good practice..
Any clues?
I also have the same issue with DBI_1.0.0 and RMySQL_0.10.16. In a Shiny App, I am using:
conn <- dbConnect(MySQL(),
user = 'xxx',
password = 'xxx',
host = 'xxx',
dbname='xxx')
#dbDisconnect(conn)
dbGetQuery(conn, "SET NAMES 'utf8'")
res <- dbSendQuery(conn, "SELECT * FROM My_DB")
Final_DB_occ <- dbFetch(res, n = Inf)
When I use dbDisconnect(conn)
in my code I get:
Error in .local(dbObj, ...) : internal error in RS_DBI_getConnection: corrupt connection handle
Without the dbDisconnect(conn)
, I eventually get to the limit (16 connections).