Skip to content

Ecto/Postgrex triggering ERROR 08P01 (protocol_violation) SimpleQuery not allowed while in extended protocol mode #50858

@perezd

Description

@perezd

Describe the problem

Attempting a basic query from my unit testing framework ExUnit (using Elixir/Ecto/Postgrex). This is a very basic test that simply queries the database (logs included below).

To Reproduce

Queries ran during test:

03:16:14.172 [debug] QUERY OK db=2.8ms
begin []
03:16:14.187 [debug] QUERY OK db=2.9ms
INSERT INTO "locations" ("name","state","zip") VALUES ($1,$2,$3),($4,$5,$6),($7,$8,$9) ["a", "CA", "95050", "b", "CA", "95050", "c", "CA", "95050"]
03:16:14.187 [debug] QUERY OK db=0.5ms
commit []
03:16:14.200 [debug] QUERY ERROR source="locations" db=0.7ms queue=0.5ms
SELECT l0."id", l0."state", l0."zip", l0."name" FROM "locations" AS l0 []
03:16:14.201 [error] Postgrex.Protocol (#PID<0.272.0>) disconnected: ** (Postgrex.Error) ERROR 08P01 (protocol_violation) SimpleQuery not allowed while in extended protocol mode

Expected behavior
Rows returned as requested. Note, this does work in a non-unit testing environment. I am able to write these queries and execute them interactively just fine, something strange is happening under test. This could be related to how they manage SQL sandboxes in Ecto? https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Sandbox.html#content

Additional data / screenshots

Table def:

CREATE SEQUENCE location_id_seq START 1 INCREMENT 1
CREATE TABLE locations (
  state VARCHAR(2) NOT NULL,
  zip VARCHAR(5) NOT NULL,
  id INT8 NOT NULL DEFAULT nextval('location_id_seq':::STRING),
  name VARCHAR(255) NOT NULL,
  CONSTRAINT "primary" PRIMARY KEY (state ASC, zip ASC, id ASC),
  FAMILY "primary" (state, zip, id, name)
)

Environment:
Cockroach version:
Build Tag: v20.1.3
Build Time: 2020/06/23 08:49:00
Distribution: CCL
Platform: linux amd64 (x86_64-unknown-linux-musl)
Go Version: go1.13.9
C Compiler: gcc 6.3.0
Build SHA-1: 7fd454f
Build Type: release

Additional context

This is very similar to what I've seen here: #41511.
Maybe should be tracked here? #33441

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