apache / apache/arrow-adbc

Let drivers handle thread-safe access to the Database object in `AdbcConnectionInit`

Open
#2,791 5 comments 0 reactions 0 assignees View on GitHub
Type: enhancement
Dominant language
C#
Stars
627
Forks
217
Avg merge
17h
Merged PRs (30d)
57

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:

```rust
/// Initialize the given connection using the loaded driver.
fn connection_init(
&self,
mut connection: ffi::FFI_AdbcConnection,
) -> Result {
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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.