Closed jonmdev closed 1 week ago
Unfortunately it is not possible at the moment. We use the binary protocol instead of the text protocol, and it requires querying all types in the database so we know how to encode extensions. One option would be for us to hardcode the result for the built-in types and this way but extensions then won't work, which I am unsure if it a problem in your case.
We have the simple connection. If we are bootstrapping types during that one maybe we could set a flag to bypass it?
One option would be for us to hardcode the result for the built-in types and this way but extensions then won't work, which I am unsure if it a problem in your case. We have the simple connection. If we are bootstrapping types during that one maybe we could set a flag to bypass it?
I am wondering if either of you @greg-rychlewski or @josevalim can perhaps guide me in an experiment to see if trying these ideas will fix the problem (ie. don't send the initialization message, and hardcode in the types).
I have set up a method to test this further if you have any ideas or can explain how it might work. I would be eager to test them.
For background, here are the relevant bits of the documentation :
ArcadeDB Server supports a subset of the Postgres wire protocol, such as connection and queries. Particularly, ArcadeDB does only support "simple" query mode and does not support SSL! Some tools compatible with Postgres may execute queries on internal Postgres tables to retrieve the schema. Those tables are not present in ArcadeDB, so it may return errors at startup.
To test this further I updated my bug project by adding the Postgrex package .ex
files directly so they can be manipulated: https://github.com/jonmdev/postgres_bug
/postgrex/
folder and the postgrex.ex
of the Postgrex module into my demo projectmix.exs
as env: [type_server_reap_after: 3 * 60_000, json_library: Jason]
{:ex_doc, ">= 0.0.0", only: :docs},
{:jason, "~> 1.0", optional: true},
{:table, "~> 0.1.0", optional: true},
{:decimal, "~> 1.5 or ~> 2.0"},
{:db_connection, "~> 2.1"}
Now I believe my bug project runs the same but directly on the package code added to my project itself (so it can be freely edited or played with).
Interestingly, they are both giving new errors with this configuration. I am guessing the Postgrex package output error differently whether added as a package or directly to the code. Or perhaps I added it wrong as code. But I don't think so.
I am getting:
2024-11-18 23:06:31.882 INFO [PostgresNetworkExecutor] PSQL:-> request for password (R - 8b) (thread=52)
2024-11-18 23:06:31.884 INFO [PostgresNetworkExecutor] PSQL:-> authentication ok (R - 8b) (thread=52)
2024-11-18 23:06:31.884 INFO [PostgresNetworkExecutor] PSQL:-> backend key data (K - 12b) (thread=52)
2024-11-18 23:06:31.885 INFO [PostgresNetworkExecutor] PSQL:-> parameter status (S - 24b) (thread=52)
2024-11-18 23:06:31.885 INFO [PostgresNetworkExecutor] PSQL:-> parameter status (S - 25b) (thread=52)
2024-11-18 23:06:31.885 INFO [PostgresNetworkExecutor] PSQL:-> parameter status (S - 25b) (thread=52)
2024-11-18 23:06:31.885 INFO [PostgresNetworkExecutor] PSQL:-> ready for query (Z - 5b) (thread=52)Exception in thread "ArcadeDB-postgres//127.0.0.1" com.arcadedb.postgres.PostgresProtocolException: Error on parsing startup message
at com.arcadedb.postgres.PostgresNetworkExecutor.readStartupMessage(PostgresNetworkExecutor.java:989)
at com.arcadedb.postgres.PostgresNetworkExecutor.run(PostgresNetworkExecutor.java:114)
Caused by: java.io.EOFException
at java.base/java.io.DataInputStream.readInt(DataInputStream.java:397)
at com.arcadedb.network.binary.ChannelBinary.readUnsignedInt(ChannelBinary.java:79)
at com.arcadedb.postgres.PostgresNetworkExecutor.readStartupMessage(PostgresNetworkExecutor.java:925)
... 1 more
Exception in thread "ArcadeDB-postgres//127.0.0.1" Exception in thread "ArcadeDB-postgres//127.0.0.1" Exception in thread "ArcadeDB-postgres//127.0.0.1" com.arcadedb.postgres.PostgresProtocolException: Error on parsing startup message
at com.arcadedb.postgres.PostgresNetworkExecutor.readStartupMessage(PostgresNetworkExecutor.java:989)
at com.arcadedb.postgres.PostgresNetworkExecutor.run(PostgresNetworkExecutor.java:114)
Caused by: java.io.EOFException
at java.base/java.io.DataInputStream.readInt(DataInputStream.java:397)
at com.arcadedb.network.binary.ChannelBinary.readUnsignedInt(ChannelBinary.java:79)
at com.arcadedb.postgres.PostgresNetworkExecutor.readStartupMessage(PostgresNetworkExecutor.java:925)
... 1 more
STARTED POSTGRES WITH STATUS: {:ok, #PID<0.182.0>}
Interactive Elixir (1.17.3) - press Ctrl+C to exit (type h() ENTER for help)
23:24:22.063 [error] :gen_statem #PID<0.185.0> terminating
** (ArgumentError) unknown registry: Postgrex.TypeManager
(elixir 1.17.3) lib/registry.ex:1400: Registry.key_info!/1
(elixir 1.17.3) lib/registry.ex:590: Registry.lookup/2
(postgres_bug 0.1.0) lib/postgrex/type_supervisor.ex:23: Postgrex.TypeSupervisor.locate/2
(postgres_bug 0.1.0) lib/postgrex/protocol.ex:1087: Postgrex.Protocol.bootstrap/3
(postgres_bug 0.1.0) lib/postgrex/protocol.ex:729: Postgrex.Protocol.handshake/3
(postgres_bug 0.1.0) lib/postgrex/protocol.ex:209: Postgrex.Protocol.connect_endpoints/6
(db_connection 2.7.0) lib/db_connection/connection.ex:74: DBConnection.Connection.handle_event/4
(stdlib 6.1.1) gen_statem.erl:3737: :gen_statem.loop_state_callback/11
Queue: [internal: {:connect, :init}]
Postponed: []
State: Postgrex.Protocol
Callback mode: :handle_event_function, state_enter: false
23:24:22.515 [error] :gen_statem #PID<0.191.0> terminating
I am not sure where this message originates from in the code. I think it is in protocol.ex
at line 199 connect_endpoints
with connect_and_handshake
which is defined further at line 249 with connect_and_handshake
which is defined further at line 723 with handshake
, and most specifically, line 732 with ref = Postgrex.Parameters.insert(parameters)
.
I am guessing that is the bottom line there? Is that what I want to override? Ie. If I can (1) stop sending the query for this to the database in case that is triggering the issue, and (2) manually set in something myself for the parameters if that is what that is, then maybe I can make it work?
Any general ideas for how this could go? If it is solvable, perhaps the solution may be generalized into a new option for the Postgrex system in these types of cases. Or not. I am not sure. Either way I appreciate any guesses or conjecture as I am sure you both understand all this far better than me. 🙏
Never mind actually. I was able to connect via Rust (which can be wrapped in Elixir). I will connect that way or via a different protocol. Thanks.
Elixir version
IEx 1.17.3 (compiled with Erlang/OTP 27)
Database and Version
ArcadeDB current
Postgrex Version
{:postgrex, "~> 0.19.3"}
Current behavior
I posted a bug report here regarding attempting to use this in generic connection to ArcadeDB which supports PostGres connection protocol.
Error
The connection attempt is crashing with the message:
Interpretation
The interpretation of this issue over there was:
Test Code
https://github.com/jonmdev/postgres_bug
Inside application.ex
Ideas?
What do you think? Do you think there is any way to solve this on the Elixir side? If so how? Or would you recommend a solution on the Arcade side? Either way how would you see that best potentially working?
If it is just a matter of not sending this generic request on connection which is crashing it, is there any way to turn that off?
Thanks for any ideas.
Expected behavior
Ideally can connect to generic Postgres adapter interfaced database.