alinaliBQ opened a new issue, #47608:
URL: https://github.com/apache/arrow/issues/47608

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Hi community, it seems the compute kernels registry is not cleared when the 
dll library (that is dynamically linked to `arrow_compute.dll`) is unloaded. Is 
this expected behavior? If not, then this might be a big impact.
   
   Please let me know if you have any questions. Here is my attempt at 
explaining the issue that our team is facing:
   * we are working on an Arrow Flight SQL ODBC driver dll 
(`arrow_flight_sql_odbc.dll`) library at 
https://github.com/apache/arrow/pull/46099, that uses `arrow_compute.dll`
   * `arrow::compute::Initialize()` is called 
[once](https://github.com/Bit-Quill/arrow/blob/46a401aa29dc18eed8dfd752d2e92a2042b98c2b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc#L62)
 from `arrow_flight_sql_odbc.dll` every time the driver dll is loaded in the 
test executable. And each test case loads the driver dll at the beginning and 
unloads at the end.
   * this means `arrow::compute::Initialize()` gets called every test case
   * this causes an issue because when the second test case starts, we receive 
`Already have a function registered with name` error and it blocks rest of 
tests from running.
   
   What the error message looks like:
   ```
   [Test 1 passes]
   [Test 2 starts]
   arrow\cpp\src\arrow\compute\kernels\scalar_arithmetic.cc:1448:  Check 
failed: _s.ok() Operation failed: 
registry->AddFunction(std::move(absolute_value))
   Bad status: Key error: Already have a function registered with name: abs
   ```
   
   I think that every dll library that calls `arrow::compute::Initialize()` 
could potentially run into this issue. This is because the application that 
uses the `dll` isn't guaranteed to know Arrow compute, so the application isn't 
expected to call `arrow::compute::Initialize()`. 
   - I can confirm this error goes away when I remove the 
`arrow::compute::Initialize()` call from the driver dll and into the test 
environment set up, but the initialization needs to happen inside the driver, 
as the driver needs to initialize the compute functions in order to work 
properly.
   
   Thanks in advance to people that are looking into this.
   
   ### Component(s)
   
   C++


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to