2

I am trying to connect to redshift database using R. Since I upgraded my mac to Monterey I receive a message in R as " R Session Aborted -R encountered a fatal error - the session was terminated" here is the code that produces the error sourcing it from here

Any advice on how to fix this error?

Connecting to RPostgreSQL

library("RPostgreSQL")
drv <- dbDriver('PostgreSQL')  
db <- 'myDatabase'  
host_db <- 'aws-us-east-1-portal.234.dblayer.com'  
db_port <- '98939'  
db_user <- 'henryviii'  
db_password <- ‘happydays’
conn <- dbConnect(drv, dbname=db, host=host_db, port=db_port, user=db_user, password=db_password)

I receive the following error when trying on terminal:

 *** caught segfault ***
address 0x8247a800, cause 'memory not mapped'

Traceback:
 1: postgresqlNewConnection(drv, ...)
 2: dbConnect(drv, dbname = db, host = host_db, port = db_port, user = db_user,     password = db_password)
 3: dbConnect(drv, dbname = db, host = host_db, port = db_port, user = db_user,     password = db_password)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

and here is an output of sessionInfo()

R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.0.1

Matrix products: default
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     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7           rstudioapi_0.13      magrittr_2.0.1       hms_1.1.1            tidyselect_1.1.1     bit_4.0.4           
 [7] R6_2.5.1             rlang_0.4.12         fansi_0.5.0          blob_1.2.2           dplyr_1.0.7          tools_4.1.2         
[13] RPostgres_1.4.3.9000 sessioninfo_1.2.2    utf8_1.2.2           cli_3.1.0            DBI_1.1.2            ellipsis_0.3.2      
[19] bit64_4.0.5          assertthat_0.2.1     tibble_3.1.6         lifecycle_1.0.1      crayon_1.4.2         purrr_0.3.4         
[25] vctrs_0.3.8          glue_1.6.0           compiler_4.1.2       pillar_1.6.4         generics_0.1.1       pkgconfig_2.0.3     ```
21
  • What is db2? It isn't defined in the linked tutorial, either. Commented Dec 28, 2021 at 19:16
  • Which expression triggers the error? If you rename db2 to db, does the crash change? Commented Dec 28, 2021 at 19:17
  • 1
    @r2evans I was able to replicate the same error through a different IDE - removed Rstudio from the Tag and add the session info. Commented Dec 28, 2021 at 20:05
  • 2
    There are certainly differences between the two, but most people will never notice them. They both provide drivers used for DBI methods, so it is a drop-in replacement. I've been trying to recommend ways to troubleshoot where the issue lies, but if you won't test RPostgres, then the only other thing I can suggest is to completely uninstall RPostgreSQL and all postgres-odbc (OS-level) drivers, download new versions of them (even if the same version, get a new copy of the downloads), and reinstall. After rebooting your OS. Good luck. Commented Dec 29, 2021 at 1:52
  • 2
    FWIW, I had a similar error to OP. Changing from RPostgreSQL::PostgreSQL() to RPostgres::Postgres() fixed the issue. Thanks @r2evans for the tip. Commented Apr 29, 2022 at 23:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.