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

sqlite: implement backup api #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

sqlite: implement backup api #17

wants to merge 3 commits into from

Conversation

crawshaw
Copy link
Member

Signed-off-by: David Crawshaw crawshaw@tailscale.com

cgosqlite/cgosqlite.go Show resolved Hide resolved
cgosqlite/cgosqlite.go Show resolved Hide resolved
cgosqlite/cgosqlite.go Show resolved Hide resolved
sqlite.go Outdated Show resolved Hide resolved
sqlite.go Outdated Show resolved Hide resolved
sqlite_test.go Show resolved Hide resolved
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
@raggi
Copy link
Member

raggi commented Feb 24, 2023

This is not safe as-is, sqlite itself does not lock results, which the backup API also uses. We will need to add a lock shared between the backup context and the connection context that serializes calls to step and query/result functions. I tested THREADSAFE=1 to see if that would do the work for us, it does not.

It is likely useful to report progress information and offer abort for
large databases, so expose this in the high level API in a somewhat safe
way.

A lock was not introduced into the driver directly at this time because
doing so is much more complex, particularly as Stmt.DBHandle would need
to recover that lock - essnetially requiring global state with further
synchronization.
@raggi
Copy link
Member

raggi commented Mar 1, 2023

TODO: test if we can perform online backups of two schemas concurrently

At time of writing control has two databases attached in the writable connection, main and noise. Ideally to backup both efficiently using the online backup API we'd be able to start a backup of both of these schemas and Step() them concurrently, and Finish() them at the same time, so the backups are in sync. It's not immediately clear if this is allowed in the backup API, so we need to test it.

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

Successfully merging this pull request may close these issues.

None yet

3 participants