Skip to content

Warn when pool_size is 1 (Ecto 2.0) #1279

@Gazler

Description

@Gazler

When the pool_size is 1, and the test_helper has something like:

Mix.Task.run "ecto.migrate", ["-r", "MyApp.Repo", "--quiet"]

The migrate task checks out the only pool and holds on to it causing the following error:

** (MatchError) no match of right hand side value: {:error, %DBConnection.Error{message: "failed to checkout using Ecto.Adapters.SQL.Sandbox.Pool"}}

13:22:05.497 [error] GenServer #PID<0.271.0> terminating
** (stop) exited in: :gen_server.call(#PID<0.233.0>, {:checkout, #Reference<0.0.7.2799>, true}, 5000)
    ** (EXIT) time out
    (stdlib) gen_server.erl:212: :gen_server.call/3
    (poolboy) src/poolboy.erl:55: :poolboy.checkout/3
    (db_connection) lib/db_connection/poolboy.ex:36: DBConnection.Poolboy.checkout/2
    (ecto) lib/ecto/adapters/sql/sandbox.ex:214: Ecto.Adapters.SQL.Sandbox.Pool.checkout/2
    (db_connection) lib/db_connection/ownership/owner.ex:83: DBConnection.Ownership.Owner.handle_call/3
    (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:661: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

We should warn in this case.

Removing pool_size from the config fixes this.

/cc @josevalim

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions