madasebrof

madasebrof

Postgrex / CockroachDB connection stopped working

Man. No idea what’s going on.

Somehow, a very stable postgrex config just seemed to stop working.

I isolated it to a new, empty project to test config…

I can connect to cockroach db via psql no problem, but no so much via postgrex.

config = [
  username: System.get_env("CDB_USERNAME"),
  password: System.get_env("CDB_PASSWORD"),
  database: System.get_env("CDB_DATABASE"),
  parameters: [options: System.get_env("CDB_OPTIONS")],
  hostname: System.get_env("CDB_HOSTNAME"),
  port: String.to_integer(System.get_env("CDB_PORT")),
  ssl: [cacertfile: Path.expand("priv/certs/ca-cert.crt")],
  stacktrace: true,
  show_sensitive_data_on_connection_error: true
]

[
  username: "*******",
  password: "**************",
  database: "************",
  parameters: [options: "--cluster=*****"],
  hostname: "*****.aws-us-east-1.cockroachlabs.cloud",
  port: 26257,
  ssl: [cacertfile: "/Users/***/dev/***/***/priv/certs/ca-cert.crt"],
  stacktrace: true,
  show_sensitive_data_on_connection_error: true
]

Postgrex.start_link(config)

I get this error:

{:ok, #PID<0.215.0>}

15:40:42.385 [error] :gen_statem #PID<0.217.0> terminating
** (ArgumentError) errors were found at the given arguments:

  * 1st argument: not a binary

    (stdlib 6.2) :binary.copy(nil)
    (postgrex 0.19.3) lib/postgrex/types.ex:137: Postgrex.Types.build_type_info/1
    (postgrex 0.19.3) lib/postgrex/protocol.ex:1134: Postgrex.Protocol.bootstrap_recv/4
    (postgrex 0.19.3) lib/postgrex/protocol.ex:729: Postgrex.Protocol.handshake/3
    (postgrex 0.19.3) 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.2) gen_statem.erl:3737: :gen_statem.loop_state_callback/11
    (stdlib 6.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Queue: [internal: {:connect, :init}]
Postponed: []
State: Postgrex.Protocol
Callback mode: :handle_event_function, state_enter: false

I’ve confirmed that the all the envs are fine, I also used env vars to connect via psql. Also, the cert file is readable, if I change that I get a cert file error.

Any thoughts or clue as to how to troubleshoot would be most appreciated!

As I said, this has been stable for months. I have no idea what could have changed.

Most Liked

garrison

garrison

Looks like something in the protocol - I’m sure someone who works on Postgrex can comment on what this code does (I haven’t the slightest), but:

It sounds like you’re using Cockroach’s hosted cloud product, and you haven’t changed anything about your setup, right? So it sounds like they probably deployed a new version and broke something. If that’s the case, perhaps you should consider contacting their support to let them know? You’re probably not the only one.

That is, of course, assuming it’s not something really weird (like a crash induced by parsing a particular date which happened to be today, or something).

garrison

garrison

lol I found it reading their release notes, looks like it’s already patched on stable

Ask them to upgrade your cluster I guess?

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement