You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "felipecrv (via GitHub)" <gi...@apache.org> on 2025/05/06 18:11:49 UTC

[PR] feat(rust): Let immutable drivers create connections [arrow-adbc]

felipecrv opened a new pull request, #2788:
URL: https://github.com/apache/arrow-adbc/pull/2788

   Since the removal of the global driver lock, there is no risk of deadlocks between the locks on the driver and on the database objects.
   
   IIUC, this was why member functions on the database struct took a mutable `self` parameter:
   
   ```rust
       /// Initialize the given database using the loaded driver.
       ///
       /// This uses `&mut self` to prevent a deadlock.
       fn database_init(
           &mut self,
           mut database: ffi::FFI_AdbcDatabase,
       ) -> Result<ffi::FFI_AdbcDatabase> {
   ```
   
   Requiring `&mut self` is overkill and requires another layer of locking at the application side if multiple threads share a database instance (as they should for connection pooling).
   
   This doesn't mean we are passing a forged mutable pointer to the driver via the FFI, the locking on the inner database ensures exclusive access to the `FFI_AdbcDatabase`.
   
   ```rust
       /// 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)
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(rust)!: Let immutable drivers create connections [arrow-adbc]

Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv merged PR #2788:
URL: https://github.com/apache/arrow-adbc/pull/2788


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org