Skip to content

Regression starting from 19.2 with Elixir / binary protocol when loading arrays #51360

@tlvenn

Description

@tlvenn

Describe the problem

Arrays use to work just fine in 19.1 but from 19.2, it seems a regression has been introduced and now Elixir / Postgrex is crashing when trying to decode an array from the DB:

[error] GenServer #PID<0.795.0> terminating
** (DBConnection.ConnectionError) client #PID<0.1054.0> stopped: ** (MatchError) no match of right hand side value: <<0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 4, 19, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 22, 117, 112, 115, 101, 114, 116, 95, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 121, 95, 107, 101, 121, 0, 0, 0, 12, ...>>
    (postgrex 0.15.5) lib/postgrex/type_module.ex:897: Postgrex.DefaultTypes."Elixir.Postgrex.Extensions.Array"/8
    (postgrex 0.15.5) lib/postgrex/protocol.ex:2870: Postgrex.Protocol.rows_recv/4
    (postgrex 0.15.5) lib/postgrex/protocol.ex:1899: Postgrex.Protocol.recv_execute/5
    (postgrex 0.15.5) lib/postgrex/protocol.ex:1773: Postgrex.Protocol.bind_execute/4
    (db_connection 2.2.2) lib/db_connection/holder.ex:316: DBConnection.Holder.holder_apply/4
    (db_connection 2.2.2) lib/db_connection.ex:1255: DBConnection.run_execute/5
    (db_connection 2.2.2) lib/db_connection.ex:1342: DBConnection.run/6
    (db_connection 2.2.2) lib/db_connection.ex:539: DBConnection.parsed_prepare_execute/5
    (db_connection 2.2.2) lib/db_connection.ex:532: DBConnection.prepare_execute/4
    (ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:534: Ecto.Adapters.SQL.execute!/4
    (ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:526: Ecto.Adapters.SQL.execute/5
    (ecto 3.4.5) lib/ecto/repo/queryable.ex:192: Ecto.Repo.Queryable.execute/4
    (ecto 3.4.5) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (stdlib 3.13) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.4) src/elixir.erl:278: :elixir.recur_eval/3
    (elixir 1.10.4) src/elixir.erl:263: :elixir.eval_forms/3
    (iex 1.10.4) lib/iex/evaluator.ex:258: IEx.Evaluator.handle_eval/5
    (iex 1.10.4) lib/iex/evaluator.ex:239: IEx.Evaluator.do_eval/3
    (iex 1.10.4) lib/iex/evaluator.ex:217: IEx.Evaluator.eval/3
    (iex 1.10.4) lib/iex/evaluator.ex:103: IEx.Evaluator.loop/1

This was first reported to me by @damboscolo in jumpn/ecto_cockroachdb#3 and I was kinda hoping it would go away with the 20.X release but unfortunately we are not so lucky ;)

To Reproduce
Create a table with a array column, in my case it is a VARCHAR(255)[] NOT NULL, insert one row in the database and query it

Expected behavior
The rows should load just fine.

Environment:

  • CockroachDB version: 20.1
  • Server OS: OSX 11
  • Client app: Postgrex / Elixir

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityX-blathers-triagedblathers was able to find an owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions