You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Go 1.21.8 is used for building some ADBC drivers and this issue can only be reproduced on x86_64 macOS. However, according to this reply
Using multiple c-shared libraries in the same process is never really supported. Currently the c-shared library assumed it is the only copy of the Go runtime in the process. Unlike plugins, it doesn't try to see if there is any other Go runtime loaded in the process and integrate with them. Having multiple c-shared libraries in the same process might work in some simple cases, where each shared library mostly works in isolation. But if the program passes pointers around, weird things can happen.
You could try building them into a single c-shared library, or using plugins. Thanks.
which means this issue could potentially happen on other platforms/architectures.
While I agree that most consumers are probably not going to use multiple drivers at the same time, we can have an alternative solution for Elixir users (who want/have to do that) by spawning remote nodes and loading one Go implemented ADBC driver in a dedicated remote node.
defmoduleAdbc.Clusterdodefspawn(drivers)do# Turn node into a distributed node with the given long name:net_kernel.start([:"[email protected]"])# Allow spawned nodes to fetch all code from this node:erl_boot_server.start([])allow_boot(to_charlist("127.0.0.1"))drivers|>Enum.map(&Task.async(fn->spawn_node(&1)end))|>Enum.map(&Task.await(&1,30_000))enddefpspawn_node({node_host,driver})do{:ok,node}=:slave.start(to_charlist("127.0.0.1"),node_name(node_host),inet_loader_args())add_code_paths(node)transfer_configuration(node)ensure_applications_started(node)start_driver(node,driver){:ok,node}enddefrpc(node,module,function,args)do:rpc.block_call(node,module,function,args)enddefpinet_loader_argsdoto_charlist("-loader inet -hosts 127.0.0.1 -setcookie #{:erlang.get_cookie()}")enddefpallow_boot(host)do{:ok,ipv4}=:inet.parse_ipv4_address(host):erl_boot_server.add_slave(ipv4)enddefpadd_code_paths(node)dorpc(node,:code,:add_paths,[:code.get_path()])enddefptransfer_configuration(node)dofor{app_name,_,_}<-Application.loaded_applications()dofor{key,val}<-Application.get_all_env(app_name)dorpc(node,Application,:put_env,[app_name,key,val])endendenddefpensure_applications_started(node)dorpc(node,Application,:ensure_all_started,[:mix])rpc(node,Mix,:env,[Mix.env()])for{app_name,_,_}<-Application.loaded_applications()dorpc(node,Application,:ensure_all_started,[app_name])endenddefpstart_driver(node,driver)doargs=[driver,[strategy: :one_for_one]]rpc(node,Supervisor,:start_link,args)enddefpnode_name(node_host)donode_host|>to_string|>String.split("@")|>Enum.at(0)|>String.to_atom()endend
test/multiple-go-drivers.exs
defmoduleAdbc.Driver.TestdouseExUnit.CasealiasAdbc.Connectionsetupdoflightsql=[{Adbc.Database,driver: :flightsql,process_options: [name: MyApp.FlightSQL]},{Adbc.Connection,database: MyApp.FlightSQL,process_options: [name: MyApp.FlightSQLConn]}]snowflake=[{Adbc.Database,driver: :snowflake,process_options: [name: MyApp.Snowflake]},{Adbc.Connection,database: MyApp.Snowflake,process_options: [name: MyApp.SnowflakeConn]}][{:ok,flightsql},{:ok,snowflake}]=Adbc.Cluster.spawn([{"flightsql",flightsql},{"snowflake",snowflake}])%{flightsql: flightsql,snowflake: snowflake}endtest"load multiple drivers",%{flightsql: flightsql,snowflake: snowflake}doAdbc.Cluster.rpc(flightsql,Adbc.Connection,:query,[MyApp.FlightSQLConn,"query that goes to flightsql"])Adbc.Cluster.rpc(snowflake,Adbc.Connection,:query,[MyApp.SnowflakeConn,"some other query that goes to snowflake"])endend
The text was updated successfully, but these errors were encountered:
As reported in apache/arrow-adbc#1841 and golang/go#65050, there can be issues when loading multiple Go implemented ADBC drivers.
Currently, Go 1.21.8 is used for building some ADBC drivers and this issue can only be reproduced on x86_64 macOS. However, according to this reply
which means this issue could potentially happen on other platforms/architectures.
While I agree that most consumers are probably not going to use multiple drivers at the same time, we can have an alternative solution for Elixir users (who want/have to do that) by spawning remote nodes and loading one Go implemented ADBC driver in a dedicated remote node.
And below is some proof-of-concept code (mostly borrowed from phoenixframework/phoenix_pubsub)
adbc_cluster.ex
test/multiple-go-drivers.exs
The text was updated successfully, but these errors were encountered: