Skip to contents

Original version: 16 October, 2023

Updating duckdb to 0.9.1

The R duckdb client version 0.9.1 cannot read databases created with previous versions of the package. The duckdb error message indicates

am_available() Error in h(simpleError(msg, call)) : error in evaluating the argument ‘drv’ in selecting a method for function ‘dbConnect’: rapi_startup: Failed to open database: IO Error: Trying to read a database file with version number 51, but we can only read version 64.

The database file was created with DuckDB version v0.8.0 or v0.8.1.

The storage of DuckDB is not yet stable; newer versions of DuckDB cannot read old database files and vice versa. The storage will be stabilized when version 1.0 releases.

For now, we recommend that you load the database file in a supported version of DuckDB, and use the EXPORT DATABASE command followed by IMPORT DATABASE on the current version of DuckDB.

See the storage page for more information: https://duckdb.org/internals/storage

but in practice the most straight-forward solution is to remove existing AlphaMissenseR data resources and ‘start again’.

The following attempts to identify AlphaMissenseR data resources cached locally

am_rids <-
    bfcinfo() |>
    dplyr::filter(
        grepl("zenodo", rname) |
        startsWith(rname, "AlphaMissense_")
    ) |>
    pull(rid)

After verifying that these resources have not been created outside AlphaMissenseR, remove them.

BiocFileCache::bfcremove(rids = am_rids)

Commands such as am_available() should report no files cached. The command

am_data("gene_hg38")
#> # Source:   table<gene_hg38> [?? x 2]
#> # Database: DuckDB v1.1.1 [mtmorgan@Darwin 23.6.0:R 4.5.0//Users/mtmorgan/Library/Caches/org.R-project.R/R/BiocFileCache/121787f1dafbc_121787f1dafbc]
#>    transcript_id      mean_am_pathogenicity
#>    <chr>                              <dbl>
#>  1 ENST00000000233.10                 0.742
#>  2 ENST00000000412.8                  0.378
#>  3 ENST00000001008.6                  0.422
#>  4 ENST00000001146.6                  0.467
#>  5 ENST00000002125.9                  0.351
#>  6 ENST00000002165.11                 0.406
#>  7 ENST00000002501.10                 0.320
#>  8 ENST00000002596.6                  0.471
#>  9 ENST00000002829.8                  0.524
#> 10 ENST00000003084.10                 0.405
#> # ℹ more rows

will re-download the file and insert it into a database that functions with duckdb 0.9.1.

Resource temporarily unavailable

Trying to access a data resource with am_data() may sometimes result in a DuckDB errors about “Resource unavailable”.

> am_data("hg38")

* [10:05:09][warning] error in evaluating the argument 'drv' in selecting a
    method for function 'dbConnect': rapi_startup: Failed to open database:
    IO Error: Could not set lock on file 
    ".../Caches/org.R-project.R/R/BiocFileCache/1ec5157ddaa2_1ec5157ddaa2":
    Resource unavailable

Error in value[[3L]](cond) :
    failed to connect to DuckDB database, see 'Issues & Solutions' vignette

This occures when the database is being used by an independent R process. The solution is to identify the process and disconnect from the database using, e.g., db_disconnect_all().

Finally

Remember to disconnect and shutdown all managed DuckDB connections.

db_disconnect_all()
#> * [09:26:57][info] disconnecting all registered connections

Database connections that are not closed correctly trigger warning messages.

Session information

sessionInfo()
#> R Under development (unstable) (2024-07-31 r86945)
#> Platform: aarch64-apple-darwin23.4.0
#> Running under: macOS Sonoma 14.6.1
#> 
#> Matrix products: default
#> BLAS:   /Users/mtmorgan/bin/R-devel/lib/libRblas.dylib 
#> LAPACK: /Users/mtmorgan/bin/R-devel/lib/libRlapack.dylib;  LAPACK version 3.12.0
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> time zone: America/New_York
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] AlphaMissenseR_1.1.10 dplyr_1.1.4          
#> 
#> loaded via a namespace (and not attached):
#>  [1] sass_0.4.9           utf8_1.2.4           generics_0.1.3      
#>  [4] spdl_0.0.5           RSQLite_2.3.7        digest_0.6.37       
#>  [7] magrittr_2.0.3       evaluate_1.0.1       grid_4.5.0          
#> [10] fastmap_1.2.0        blob_1.2.4           jsonlite_1.8.9      
#> [13] whisker_0.4.1        DBI_1.2.3            httr_1.4.7          
#> [16] purrr_1.0.2          fansi_1.0.6          scales_1.3.0        
#> [19] textshaping_0.4.0    jquerylib_0.1.4      duckdb_1.1.1        
#> [22] cli_3.6.3            rlang_1.1.4          dbplyr_2.5.0        
#> [25] munsell_0.5.1        bit64_4.5.2          withr_3.0.1         
#> [28] cachem_1.1.0         yaml_2.3.10          BiocBaseUtils_1.7.3 
#> [31] tools_4.5.0          memoise_2.0.1        colorspace_2.1-1    
#> [34] ggplot2_3.5.1        filelock_1.0.3       curl_5.2.3          
#> [37] rjsoncons_1.3.1      vctrs_0.6.5          R6_2.5.1            
#> [40] BiocFileCache_2.13.2 lifecycle_1.0.4      RcppSpdlog_0.0.18   
#> [43] fs_1.6.4             htmlwidgets_1.6.4    bit_4.5.0           
#> [46] ragg_1.3.3           pkgconfig_2.0.3      desc_1.4.3          
#> [49] pkgdown_2.1.1        pillar_1.9.0         bslib_0.8.0         
#> [52] gtable_0.3.6         Rcpp_1.0.13          glue_1.8.0          
#> [55] systemfonts_1.1.0    xfun_0.48            tibble_3.2.1        
#> [58] tidyselect_1.2.1     knitr_1.48           htmltools_0.5.8.1   
#> [61] rmarkdown_2.28       compiler_4.5.0