felipecrv opened a new issue, #2715:
URL: https://github.com/apache/arrow-adbc/issues/2715

   ### What happened?
   
   Statement execution is unnecessarily serialized when issuing statements from 
multiple threads even when each thread has their own dedicated `Connection`.
   
   This happens because a lock on the driver is acquired for every operation, 
so there is no chance of parallelization when using an ADBC driver from Rust.
   
   ```rust
       fn execute(&mut self) -> Result<impl RecordBatchReader> {
           let driver = 
&self.inner.connection.database.driver.driver.lock().unwrap();
           let mut statement = self.inner.statement.lock().unwrap();
           let mut error = ffi::FFI_AdbcError::with_driver(driver);
           let method = driver_method!(driver, StatementExecuteQuery);
           let mut stream = FFI_ArrowArrayStream::empty();
           let status = unsafe { method(statement.deref_mut(), &mut stream, 
null_mut(), &mut error) };
           check_status(status, error)?;
           let reader = ArrowArrayStreamReader::try_new(stream)?;
           Ok(reader)
       }
   
   ```
   
   Creating connections can also prevent the execution of statements, because 
connection creation also needs a lock on the driver.
   
   ```rust
       /// Returns a new connection using the loaded driver.
       ///
       /// This uses `&mut self` to prevent a deadlock.
       fn connection_new(&mut self) -> Result<ffi::FFI_AdbcConnection> {
           let driver = &self.inner.driver.driver.lock().unwrap();
           let mut connection = ffi::FFI_AdbcConnection::default();
   
           // ConnectionNew
           let mut error = ffi::FFI_AdbcError::with_driver(driver);
           let method = driver_method!(driver, ConnectionNew);
           let status = unsafe { method(&mut connection, &mut error) };
           check_status(status, error)?;
   
           Ok(connection)
       }
   ```
   
   ### Stack Trace
   
   _No response_
   
   ### How can we reproduce the bug?
   
   _No response_
   
   ### Environment/Setup
   
   _No response_


-- 
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: issues-unsubscr...@arrow.apache.org.apache.org

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

Reply via email to