Closed mjsteinbaugh closed 6 years ago
I will look into this. The next time this occurs could you please post your command history.
Sure! I will add a minimal example needed to reproduce this when I get a chance. Thanks.
I have the same thing, loading the example gtf from GenomicFeatures, which uses AnnotationDbi. My package gives the same warning in tests, and removing the txdb object does not help.
Reproducable example: library(GenomicFeatures) samplefile <- system.file("extdata", "hg19_knownGene_sample.sqlite", package = "GenomicFeatures") txdb <- loadDb(samplefile) fiveUTRs <- fiveUTRsByTranscript(txdb) # <- extract only 5' leaders fiveUTRs[1] fiveUTRs[2] rm(fiveUTRs) while(1){print("hello there")}
warning: call dbDisconnect() when finished working with a connection
@Roleren Actually, this doesn't reproduce for me -- what does your sessionInfo() say?
@mtmorgan hm, when I restarted session and tried again, it did not reproduce, will try to make one that actually reproduces..
@mtmorgan Yeah that's similar to what's happening for me. I don't get the dbDisconnect()
warning consistently, so this is hard to reproduce exactly.
options(warn=1)
suppressPackageStartupMessages({
library("GenomicFeatures")
})
fl <- system.file(
package = "GenomicFeatures", "extdata", "hg19_knownGene_sample.sqlite"
)
while(TRUE) {
loadDb(fl)
gc()
}
throws the 'warning' (in quotes because it doesn't seem to be a real warning, https://github.com/r-dbi/RSQLite/issues/245 ) consistently.
I've updated AnnotationDbi v. 1.41.4 (i.e., the 'devel' version) so that it closes any connections left open; to avoid the error in GenomicFeatures, you need to update GenomicFeatures (to 1.31.1). These are both available now from their Bioconductor (and GitHub) repositories, and via biocLite()
probably on Monday after about 2pm Eastern.
Circling back, I'm still seeing this error intermittently with my code that queries AnnotationHub via AnnotationHub::query()
. Here's an updated stack trace:
options("warn" = 2L)
AcidGenomes::makeGRangesFromEnsembl(organism = "Homo sapiens")
Error: (converted from warning) call dbDisconnect() when finished working with a connection
Backtrace:
▆
1. ├─AcidGenomes::makeGRangesFromEnsembl(organism = "Homo sapiens")
2. │ └─AcidGenomes:::.getEnsDb(...)
3. │ └─AcidGenomes:::.getEnsDbAnnotationHubID(...)
4. │ ├─AnnotationHub::query(...)
5. │ └─AnnotationHub::query(...)
6. │ └─AnnotationHub .local(x, pattern, ...)
7. │ └─x[idx]
8. │ └─methods `<fn>`(`<list>`, `<stndrdGn>`, `<env>`)
9. │ └─methods:::.findInheritedMethods(classes, fdef, mtable)
10. └─RSQLite `<fn>`(`<externalptr>`)
11. ├─RSQLite:::warning_once("call dbDisconnect() when finished working with a connection")
12. │ ├─base::withVisible(eval(mc, parent.frame()))
13. │ └─base::eval(mc, parent.frame())
14. │ └─base::eval(mc, parent.frame())
15. └─RSQLite `<fn>`("call dbDisconnect() when finished working with a connection")
hmmm... again tough to debug since its intermittent as I just tried running and did not get an error. What is your sessionInfo()
@jorainer let me know if you have any thoughts as well. It looks like the resource that is being retrieved is an EnsDb object. Internally the hubs call ensembldb::EnsDb()
@lshep Sure thing, here's my current session info:
utils::sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/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 methods base
other attached packages:
[1] AcidGenomes_0.3.0.9000 AcidDevTools_0.4.6
loaded via a namespace (and not attached):
[1] compiler_4.1.2 pillar_1.7.0 GenomeInfoDb_1.30.1
[4] XVector_0.34.0 bitops_1.0-7 syntactic_0.5.1.9000
[7] tools_4.1.2 zlibbioc_1.40.0 AcidBase_0.5.0.9000
[10] tibble_3.1.6 lifecycle_1.0.1 lattice_0.20-45
[13] pkgconfig_2.0.3 rlang_1.0.1 Matrix_1.4-0
[16] AcidCLI_0.1.8.9000 cli_3.2.0 parallel_4.1.2
[19] GenomeInfoDbData_1.2.7 AcidPlyr_0.2.0.9000 httr_1.4.2
[22] stringr_1.4.0 S4Vectors_0.32.3 vctrs_0.3.8
[25] IRanges_2.28.0 stats4_4.1.2 grid_4.1.2
[28] pipette_0.8.0.9000 glue_1.6.2 data.table_1.14.2
[31] R6_2.5.1 processx_3.5.2 fansi_1.0.2
[34] magrittr_2.0.2 ps_1.6.0 AcidGenerics_0.6.0.9000
[37] ellipsis_0.3.2 BiocGenerics_0.40.0 GenomicRanges_1.46.1
[40] goalie_0.6.0.9000 utf8_1.2.2 stringi_1.7.6
[43] RCurl_1.98-1.6 crayon_1.5.0 BiocIO_1.4.0
Hm, I can have a look at the code - but I also randomly get this message in R - sometimes unrelated to EnsDb
s or TxDb
s but just while working with SQLite databases.
If I'm not wrong EnsDb
and TxDb
databases open the SQLite connection, but maybe never close it? Maybe that could be related to this issue? I'm also wondering what happens with the database connection if the variable/EnsDb
gets deleted... is there something like a destructor call for R S4 objects? Something like on.exit
, but for a S4object that could close the connection when the variable gets deleted?
@jorainer You might want to check ?reg.finalizer
. Can't remember if something like this is used for TxDb objects.
Occasionally when using AnnotationHub I get this warning following a database query:
I noticed that this is popping up in some of the Bioconductor documentation pages as well – Google search. Is there a way to either suppress or fix this warning? It seems to be related to SQL queries not closing out correctly.