Description
Queries that run without any issues in version "0.9-3' now do not work in "0.10.1".
In one of my tests, I removed columns one by one and things worked properly when I got down to 203 columns. I thought perhaps there was a problem with the last one I removed, but that is not the case. If I remove another one instead, the same issue occurs. This is the message:
Error in validObject(.Object) :
invalid class “MySQLResult” object: invalid object for slot "Id" in class "MySQLResult": got class "list", should be or extend class "integer"
Calls: dbSendQuery ... .local -> new -> initialize -> initialize -> validObject
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted
In another situation (involving a JOIN of 2 tables), if I list out all the columns (270 in total), the query works, but if I write it as SELECT table1., table2. FROM ... , then it fails. The message is:
Error in is(object, Cl) :
INTEGER() can only be applied to a 'integer', not a 'char'
Calls: fetch -> .valueClassTest -> is -> is -> .Call
Execution halted
To repeat, the queries are all valid and work perfectly in MySQL (issuing direct commands) and in the older version of this library (RMySQL 0.9-3) which I have installed on another machine.
I have placed a test schema for you here:
https://heartsys.org/share/foo.tar.gz
Simply run "SELECT * FROM foo.tbl" to reproduce issue #1.
P.S. This is the version of R I am running:
R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
Activity
hadley commentedon Feb 17, 2015
Could you please try with the dev version?
noktilux commentedon Feb 19, 2015
hadley.
can you please provide me with a link to the dev version? i am only seeing for windows binaries (here : http://cran.r-project.org/web/packages/RMySQL/index.html) and i run GNU-linux.
hadley commentedon Feb 19, 2015
https://github.com/rstats-db/RMySQL ...
noktilux commentedon Feb 19, 2015
thanks. i will give it a go in the next couple of days.
MJFitzpatrick86 commentedon Jul 31, 2015
Was a solution to this every figured out? (I am trying to solve a similar problem with the same error message.)
krlmlr commentedon Oct 27, 2015
@noktilux: Any updates here?
@MJFitzpatrick86: Could you please post a reproducible example?
realgithup commentedon Oct 30, 2015
I am facing the same problem. Trying to fetch data for thousand companies in a loop. After 30-40 companies it generates the above error. Even dev version has this issue. I get the following error
Error in validObject(.Object) :
invalid class "MySQLResult" object: invalid object for slot "Id" in class "MySQLResult": got class "character", should be or extend class "integer"
I had to use version 0.9.3. But that version sometimes generates "caught segfault" error.
hadley commentedon Oct 30, 2015
@realgithup we can't help with a reproducible example
makoshark commentedon Dec 26, 2015
This is a real bug although it does seem to be one of those nasty "sometimes" errors. I got this error running an R script and then re-ran the same script on the same machine, absolutely no changes, no restarting MySQL, and it worked just fine.
cturbelin commentedon Feb 17, 2016
Hi,
This is a very strange situation. I have exactly the same error and it's very hard to reproduce.
If I run the exact same query outside my script, it runs without any error and I can't get why.
So I'm not able to create a test case.
I dont know if this can help : if I add the line "dbColumnInfo(con, table) just before the call to the dbGetQuery call, the query is executed without any error (with table=the table used in dbGetQuery).
SessionInfo():
R version 3.2.1 (2015-06-18)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.3 (Santiago)
locale:
[1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C
[3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8
[5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8
[7] LC_PAPER=fr_FR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] methods stats graphics grDevices utils datasets base
other attached packages:
[1] RColorBrewer_1.1-2 ggplot2_2.0.0 RMySQL_0.10.8 DBI_0.3.1
[5] Cairo_1.5-9
Best.
krlmlr commentedon Feb 29, 2016
@cturbelin: Thanks. The R code and a dump of the database schema could help narrow down this issue.
vst commentedon Mar 27, 2016
@cturbelin: Confirmed that your
dbColumnInfo
hack worked in my case, too.I have been seeing this error on Mac OSX once in a while when I was running repetitive big queries.
But, when I moved to a Docker container running Debian 8.3, one of those repetitive big queries never worked. Same database server...
When I called the
dbColumnInfo
once before the mentioned series of queries (I mean only once), it managed to get through without any problems.PS: The R routine is basically iterating over a stock symbols vector of length ~8000, and issuing an SQL query to retrieve their OHLC series from the database. Simple query, simple DB structure.
vst commentedon Apr 12, 2016
OK, I have experienced another problem which looks like related to this.
As mentioned in the my previous comment, we have been calling the
DBI::dbColumnInfo
before attempting to read from the database table. Snippet from the R routine:Yesterday, our system has stopped in the middle of the day with this error message, right after printing the output of the first
DBI::dbColumnInfo
output:(Why does the call trace state
dbSendQuery
twice, right?)Now... I know that we are running state machines and such errors must be reproducable. However, same Docker image running on local machine worked fine with the same database dump.
Going back to the server experiencing the problem, I've added a print statement for debugging purposes and it worked everytime when the script is run:
(Yep, I am surprised, too.)
I have quickly checked the C code for a possible problem in result set management, but couldn't find any. It looks short, precise and perfectly fine.
Then guess what: I have removed the blind hack entirely (including the
print
statement), and it never gave me the error message which it used to produce 2 weeks ago.I am entirely clueless and don't want to waste package contributors' time... Could you address some functions in R and/or C/++ code which I can play with and see if I can produce some meaningful debugging information?
Added dbColumeInfo
MrDAndersen commentedon Sep 20, 2016
I am running into a similar issue. When running a sequence of queries using
DBI::dbGetQuery
, I intermittenly get theError in validObject(.Object) : invalid class “MySQLResult” object: invalid object for slot "Id" in class "MySQLResult": got class "list", should be or extend class "integer"
error. It seems most likely it is the second of the queries that is failing, but not all the time.eddy85br commentedon Sep 20, 2016
Impressively, here the same "blind hack" worked.
I'm doing a big query with 5 left joins.
It only worked by doing
dbColumnInfo(con, "table_name")
in all 6 tables used in the large select query, like this:cocinerox commentedon Sep 24, 2016
Similar issue. Same workaround solved it.
renkun-ken commentedon May 2, 2017
Executing via
Rscript
, I trieddbColumnInfo
but this ends up with the following error:In R terminal, the error is
or
renkun-ken commentedon May 2, 2017
Through some experiments, I find that when
select *
orselect A, B, C, ...
where * or the specified columns represent more than 144DECIMAL
columns, the error will occur.renkun-ken commentedon May 2, 2017
When I adjust
MySQL()
toMySQL(fetch.default.rec = 10000)
then the error is magically gone.thornad commentedon May 11, 2017
@renkun-ken The "adjust MySQL() to MySQL(fetch.default.rec = 10000) then the error is magically gone"
worked for me too. Thanks for finding a solution for what the RMySQL developers should have fixed long ago.
renkun-ken commentedon Jun 13, 2017
MySQL(fetch.default.rec = 10000)
only works in RStudio, not in R terminal. The same code works fine in RStudio but crashes every time in R terminal. When the script is added tocrontab
, it crashes every time.