Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

garbage-collection warning despite using shutdown -- only when dbdir is specified #60

Closed
cboettig opened this issue Jan 2, 2024 · 6 comments
Milestone

Comments

@cboettig
Copy link

cboettig commented Jan 2, 2024

When the connection is created with disk-base storage, the following gives the infamous garbage-collection warning (#34, #58) when gc() is called, despite already being correctly shutdown as directed:

dir <- tempfile()
con <- DBI::dbConnect(duckdb::duckdb(), dir)
DBI::dbDisconnect(con, shutdown=TRUE)
gc()

#          used (Mb) gc trigger (Mb) max used (Mb)
# Ncells  732512 39.2    1403478   75  1403478 75.0
# Vcells 1236192  9.5    8388608   64  2328637 17.8
# Warning message:
# Database is garbage-collected, use dbDisconnect(con, shutdown=TRUE) or duckdb::duckdb_shutdown(drv) to avoid this. 

Without the dbdir argument, we do not get a warning:

con <- DBI::dbConnect(duckdb::duckdb())
DBI::dbDisconnect(con, shutdown=TRUE)
gc()

Any advice on suppressing this warning? (I have a few packages that wrap duckdb and users are frequently confused by seeing this warning, mistaking it for an error).

@kent37
Copy link

kent37 commented Feb 29, 2024

I'm seeing the same issue when using withr::defer() to call dbDisconnect(). This may be associated with upgrading duckdb to 0.9.2-1 from 0.8.1.

@krlmlr krlmlr added this to the 0.10.0 milestone Mar 3, 2024
@krlmlr
Copy link
Collaborator

krlmlr commented Mar 3, 2024

It's likely related to #83.

@kent37
Copy link

kent37 commented Mar 3, 2024

A workaround is to pass dir (and other parameters such as read_only) to duckdb() directly.

dir <- tempfile()
con <- DBI::dbConnect(duckdb::duckdb(dbdir=dir))
DBI::dbDisconnect(con, shutdown=TRUE)
gc()
          used  (Mb) gc trigger  (Mb) limit (Mb) max used  (Mb)
Ncells 2781362 148.6    4843155 258.7         NA  4843155 258.7
Vcells 6018443  46.0   12255594  93.6      16384  9301840  71.0

@krlmlr
Copy link
Collaborator

krlmlr commented Mar 24, 2024

This looks much better in #124, I'll merge it today, binaries will be available on https://duckdb.r-universe.dev/duckdb# soon. Can you confirm?

@krlmlr
Copy link
Collaborator

krlmlr commented Apr 24, 2024

Is this still an issue with v0.10.1, on CRAN now?

@kent37
Copy link

kent37 commented Apr 24, 2024

Yes, it is fixed for me in v0.10.1. Neither the reprex at the start of this issue nor my presenting issue gives the "Database is garbage-collected" warning.

@krlmlr krlmlr closed this as completed Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants