r-dbi / dbi3

DBI revisited
https://r-dbi.github.io/dbi3
37 stars 2 forks source link

Think about asynchronous operations #19

Open krlmlr opened 8 years ago

krlmlr commented 8 years ago

Important for "big data" backends.

hadley commented 8 years ago

Also need to make sure everything is cleaned up correctly if there is an interrupt. This is quite hard.

krlmlr commented 8 years ago

To me, it looks like we need to add the following methods to DBI:

dbSendQuery() and dbSendUpdate() (#20) can be non-blocking by default at the backend's choice, only dbFetch() and dbWait() and perhaps dbGetRowsAffected() are blocking. Query cancellation would be done by dbClearResult().

I think this is backwards-compatible to the current specification.

krlmlr commented 8 years ago

On second thought, it's safer to be explicit and define dbSendQueryAsync() and dbSendUpdateAsync(). The default DBI implementation of dbSendQuery() could be:

res <- dbSendQueryAsync(con, sql)
dbWait(res)
res

Similar for dbSendUpdate().

happyshows commented 7 years ago

@krlmlr any update on the asynchronous methods?

krlmlr commented 5 years ago

I think in practice it's important to ensure at least that dbFetch() and dbGetRowsAffected() are safely interruptible. This means to me:

Once this is in place, adding a timeout means checking elapsed time with each checkInterrupt() call, or perhaps scheduling a signal with timer_create().

krlmlr commented 4 years ago

This issue is about safe interruption of fetching, once the database has started delivering data. r-dbi/DBI#290 is about query cancellation, which looks like an entirely different problem.

krlmlr commented 3 years ago

Let's flesh this out in RPostgres.