Support pinning DB instances (1.3) #272
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a backport of the PR #238 to
v1.3-ossivalis
stable branch.Currently when the last connection to a DB instance is closed, this DB instance is destroyed.
This is not a big problem with file DBs, where subsequent connection from the same process can just re-open the file (though some state, like attached DBs is lost), but this is a problem with tagged in-memory DBs (
jdbc:duckdb:memory:tag1
URLs), where all DB state is lost when the DB is closed.This does not apply to untagged
:memory:
DBs, which are private to a single connection.This change adds new connection property
jdbc_pin_db
(boolean,false
by default), when it is enabled, then the DB is pinned and is kept alive in-memory even after the last connection to it is closed.DuckDBDriver.releaseDB(url)
method is added to allow client code to release such DBs.DBs that are left pinned are released automatically on JVM shutdown.
Testing: new test added.