-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
sqlite: expose backup api #56253
base: main
Are you sure you want to change the base?
sqlite: expose backup api #56253
Conversation
6c61b4c
to
9b80c2d
Compare
632edd3
to
174ace5
Compare
174ace5
to
2aee11d
Compare
This comment mentions that The backup can be performed synchronously but I don't think it should be like that. I wonder if indeed this PR would be more suitable for async API. Any thoughts? Thanks in advance |
69a3bf3
to
bd43083
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56253 +/- ##
==========================================
+ Coverage 89.18% 89.19% +0.01%
==========================================
Files 662 662
Lines 191759 192031 +272
Branches 36911 36968 +57
==========================================
+ Hits 171017 171291 +274
+ Misses 13613 13576 -37
- Partials 7129 7164 +35
|
if (try_catch.HasCaught()) { | ||
Cleanup(); | ||
|
||
resolver->Reject(env()->context(), try_catch.Exception()).ToChecked(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably best to check try_catch.CanContinue()
before calling Reject
to check for fatal errors that are terminating the isolate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do that I think we need to let somehow the user know that the backup is happening even though the progress
function is not called.
I added the CanContinue
to check and ran the test below.
await database.backup('database.bkp', {
progress: () => {.throw 'something went wrong'; }
});
For this progress
function the CanContinue
is true. The backup is finished but there's no progress information. I wonder if it might lead to confusion.
Maybe we can emit a warning or something?
Thanks a lot, @jasnell |
ca148e0
to
666034f
Compare
Hi hi @cjihrig . Could you share your thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't made it through the changes in src/node_sqlite.cc
yet, but left some comments. This also needs docs before landing.
371f368
to
a92e692
Compare
a92e692
to
fa23c05
Compare
Closes #55413
This PR exposes the SQLite Online Backup API, which allows database backup.
The API is inspired by better-sqlite3 https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#backupdestination-options---promise.
Multithreading caveats
As long as writes come from the same process and handle (
sqlite*
), the backup will continue progressing as expected. Other than that, it can cause the backup process to restart. From docs: