-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
ExtendedTask and db connections with pool - unexpected behavior - bad_weak_ptr #4145
Comments
I'm not sure why the example works through calling The problem discussed over there is that we can't pass database connections from one process to another. You have to make sure the background process gets a new connection. This can be done by setting
Also note:
|
@ismirsehregal thank you so much! I can't really understand exactly why the poolcheckout helps either unless it somehow clears out something in the pool and forces a new connection to be provided to the extendedtask future process. I think i'm going to be able to work within the constraints mentioned in the linked issue. One thing i guess I would recommend is that the documentation for extendedtask on the Shiny site do a little more to explicitly state that passing database connection objects into those functions is fraught and help with some best practices. This is important since probably there are a lot of these extendedtasks that are really just database operations. |
@benhmin I would suggest to leave the issue opened as a reminder to update the documentation. I would also be interested to know why your above example works. Cheers |
System details
Browser Version:
using internal RStudio browser (run in viewer pane)
Output of
sessionInfo()
:Example application or steps to reproduce the problem
Describe the problem in detail
I have been working on developing several apps using the ExtendedTask framework. Typically the "extended" portion of tasks in my apps involves retrieving data from or doing operations on databases. I also typically use the Pool package to create a pool of connections to the databases I use.
This is an example app that details a problem I have recently encountered when attempting to pass a pool connection into a function via ExtendedTask.
You can see I create a local database with the mtcars data set in a sqlite file. I connect to that database with a connection pool.
In my extended task invocation I pass the input$cyl and pool as parameters to data_get. The problem: if I don't put this
p <- poolCheckout(pool)
line in the observeEvent() handler then I get the following output:This can be reproduced by commenting out that line as indicated in the code. I have no idea why checking out a connection from the pool would make any difference within the observer, especially since I don't even pass
p
to the data_get invocation (in fact, it doesn't work if i try that - same error is returned).I only figured out I could make it work this way when I was trying desperate things to get rid of the bad_weak_ptr error, not because I have any idea why it makes it work.
Thanks!
The text was updated successfully, but these errors were encountered: