R 实例失败 +远程数据库连接

发布于 2024-11-24 05:18:03 字数 181 浏览 4 评论 0原文

简单问题:我使用 RODBC 连接以批处理模式并行运行多个 R 实例,并且随机一个(或多个)实例出现故障。如果我回去一一运行实例,所有实例都会成功。日志中没有错误,我只是想推断问题到底出在哪里。我的主要假设是,我遇到了内存堆顶部并且实例失败,或者(更有可能)RODCB 连接发生某种超时。有什么建议吗?

谢谢,

吉姆

Quick question: I am running multiple R instances parallel in batch mode using an RODBC connection, and randomly one (or more) of my instances is failing. If I go back and run the instances one by one, all of them are successful. There is no error in the log, and I am just trying to deduce where exactly the issue is coming from. My main hypotheses are that I am hitting a memory heap top and the instance is failing, or (more probably) there is some kind of time out happening with the RODCB connection. Any suggestions?

Thanks,

Jim

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南巷近海 2024-12-01 05:18:03

目前尚不清楚为什么没有错误显示,也许您可​​以尝试 options(error = recovery)

我曾经在使用多个数据库连接时收到以下错误:

Error in mysqlExecStatement(conn, statement, ...) : 
  RS-DBI driver: (connection with pending rows, close resultSet before continuing)

我通过发出以下行来关闭来避免此错误在发出新查询之前是否有任何打开的连接:

lapply(dbListConnections(MySQL()), dbDisconnect)

我从 获取此代码帮助列表


更新:我的一位合作者创建了函数套件 促进数据库交互,包括db.condb.opendb.closedb.query > 可以这样使用:

## load functions
source("https://raw.github.com/PecanProject/pecan/master/db/R/utils.R")

## example
params <- list(dbname = "mydb", username = "myname", password = "!#@?$")
con <- db.open(params)
mydata <- db.query("select * from mytable;")
db.close(con)

It is not clear why no error shows, perhaps you could try options(error = recover)

I used to get the following error when using multiple database connections:

Error in mysqlExecStatement(conn, statement, ...) : 
  RS-DBI driver: (connection with pending rows, close resultSet before continuing)

I avoid this error by issuing the following line to close any open connections before issuing a new query:

lapply(dbListConnections(MySQL()), dbDisconnect)

I took this code from the R help list.


update: one of my collaborators has created a suite of functions to facilitate database interactions, including db.con, db.open, db.close, and db.query that could be used like:

## load functions
source("https://raw.github.com/PecanProject/pecan/master/db/R/utils.R")

## example
params <- list(dbname = "mydb", username = "myname", password = "!#@?$")
con <- db.open(params)
mydata <- db.query("select * from mytable;")
db.close(con)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文