diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ef0728..fe1223f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,10 @@ jobs: matrix: include: - pair: - elixir: 1.8.2 - otp: 20.3 + elixir: 1.11 + otp: 23.0 - pair: - elixir: 1.14.3 + elixir: 1.17 otp: 25.3 lint: lint steps: diff --git a/integration_test/ownership/test_helper.exs b/integration_test/ownership/test_helper.exs index a9655e3..47e4327 100644 --- a/integration_test/ownership/test_helper.exs +++ b/integration_test/ownership/test_helper.exs @@ -1,9 +1,7 @@ -excludes = if Version.match?(System.version(), ">= 1.8.0"), do: [], else: [:requires_callers] - ExUnit.start( capture_log: true, assert_receive_timeout: 1000, - exclude: [:idle_time, :idle_interval | excludes] + exclude: [:idle_time, :idle_interval] ) Code.require_file("../../test/test_support.exs", __DIR__) diff --git a/lib/db_connection/connection_pool.ex b/lib/db_connection/connection_pool.ex index 7b15529..0bfd632 100644 --- a/lib/db_connection/connection_pool.ex +++ b/lib/db_connection/connection_pool.ex @@ -52,7 +52,7 @@ defmodule DBConnection.ConnectionPool do def init({mod, opts}) do DBConnection.register_as_pool(mod) - queue = :ets.new(__MODULE__.Queue, [:protected, :ordered_set]) + queue = :ets.new(__MODULE__.Queue, [:protected, :ordered_set, decentralized_counters: true]) ts = {System.monotonic_time(), 0} {:ok, _} = DBConnection.ConnectionPool.Pool.start_supervised(queue, mod, opts) target = Keyword.get(opts, :queue_target, @queue_target) diff --git a/lib/db_connection/holder.ex b/lib/db_connection/holder.ex index 8287334..83f4be6 100644 --- a/lib/db_connection/holder.ex +++ b/lib/db_connection/holder.ex @@ -17,7 +17,7 @@ defmodule DBConnection.Holder do @spec new(pid, reference, module, term) :: t def new(pool, ref, mod, state) do # Insert before setting heir so that pool can't receive empty table - holder = :ets.new(__MODULE__, [:public, :ordered_set]) + holder = :ets.new(__MODULE__, [:public, :ordered_set, decentralized_counters: true]) conn = conn(connection: self(), module: mod, state: state, ts: System.monotonic_time()) true = :ets.insert_new(holder, conn) diff --git a/lib/db_connection/ownership/manager.ex b/lib/db_connection/ownership/manager.ex index 91a435c..c8baeaa 100644 --- a/lib/db_connection/ownership/manager.ex +++ b/lib/db_connection/ownership/manager.ex @@ -74,7 +74,13 @@ defmodule DBConnection.Ownership.Manager do ets = case Keyword.fetch(owner_opts, :name) do {:ok, name} when is_atom(name) -> - :ets.new(name, [:set, :named_table, :protected, read_concurrency: true]) + :ets.new(name, [ + :set, + :named_table, + :protected, + read_concurrency: true, + decentralized_counters: true + ]) _ -> nil diff --git a/mix.exs b/mix.exs index da224c8..010a6eb 100644 --- a/mix.exs +++ b/mix.exs @@ -3,13 +3,13 @@ defmodule DBConnection.Mixfile do @source_url "https://github.com/elixir-ecto/db_connection" @pools [:connection_pool, :ownership] - @version "2.7.0" + @version "2.8.0-dev" def project do [ app: :db_connection, version: @version, - elixir: "~> 1.8", + elixir: "~> 1.11", deps: deps(), docs: docs(), description: description(), diff --git a/test/db_connection_test.exs b/test/db_connection_test.exs index 473b18a..e23cba4 100644 --- a/test/db_connection_test.exs +++ b/test/db_connection_test.exs @@ -63,21 +63,23 @@ defmodule DBConnectionTest do end describe "connection_module/1" do - test "returns the connection module when given a pool pid" do - {:ok, pool} = P.start_link([]) + setup do + {:ok, agent} = A.start_link([{:ok, :state}, {:idle, :state}, {:idle, :state}]) + [agent: agent] + end + + test "returns the connection module when given a pool pid", %{agent: agent} do + {:ok, pool} = P.start_link(agent: agent) assert {:ok, TestConnection} = DBConnection.connection_module(pool) end - test "returns the connection module when given a pool name", %{test: name} do - {:ok, _pool} = P.start_link(name: name) + test "returns the connection module when given a pool name", %{test: name, agent: agent} do + {:ok, _pool} = P.start_link(name: name, agent: agent) assert {:ok, TestConnection} = DBConnection.connection_module(name) end - test "returns the connection module when given a locked connection reference" do - {:ok, agent} = A.start_link([{:ok, :state}, {:idle, :state}, {:idle, :state}]) - - opts = [agent: agent] - {:ok, pool} = P.start_link(opts) + test "returns the connection module when given a locked connection reference", %{agent: agent} do + {:ok, pool} = P.start_link(agent: agent) P.run(pool, fn conn -> assert {:ok, TestConnection} = DBConnection.connection_module(conn)