-
Notifications
You must be signed in to change notification settings - Fork 182
Description
What feature or improvement would you like to see?
Let drivers handle thread-safe access to the Database object in AdbcConnectionInit
This would make locking more fine-grained and remove the need for a pessimistic lock around the entire AdbcConnectionInit call.
For instance, this is how Rust's driver manager wraps the FFI call today:
/// Initialize the given connection using the loaded driver.
fn connection_init(
&self,
mut connection: ffi::FFI_AdbcConnection,
) -> Result<ffi::FFI_AdbcConnection> {
let driver = self.ffi_driver();
let mut database = self.inner.database.lock().unwrap();
// ConnectionInit
let mut error = ffi::FFI_AdbcError::with_driver(driver);
let method = driver_method!(driver, ConnectionInit);
let status = unsafe { method(&mut connection, &mut *database, &mut error) };
check_status(status, error)?;
Ok(connection)
}As connection initialization can mutate the database object that initializes the connection, a lock on self.inner.database must be acquired before the call.
A driver performing multi-step auth actions might be waiting on slow HTTP requests during the AdbcConnectionInit call. If the driver took responsibility of the locking, it could let these HTTP calls happen in parallel and only synchronize the actual mutations to the database object (e.g. caching obtained info for re-use).