From 690e86d1bf199cbec5e24797b4a3aaf18b7ff640 Mon Sep 17 00:00:00 2001 From: "@wimwian" Date: Sun, 26 Jul 2026 10:55:06 +0530 Subject: [PATCH 1/4] fix: remove unused require Logger EventStore.Storage.Lock and EventStore.Storage.Database never call any Logger.* function, so `require Logger` triggers an "unused require Logger" warning on Elixir 1.20. Removing it since it has no effect on behavior. (cherry picked from commit 364bf7d228be2cd5752f8b374eadaf23711bc289) Signed-off-by: Yordis Prieto --- lib/event_store/storage/database.ex | 2 -- lib/event_store/storage/lock.ex | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/event_store/storage/database.ex b/lib/event_store/storage/database.ex index a7eabc0e..2cb15fd8 100644 --- a/lib/event_store/storage/database.ex +++ b/lib/event_store/storage/database.ex @@ -1,8 +1,6 @@ defmodule EventStore.Storage.Database do @moduledoc false - require Logger - def create(config), do: storage_up(config) def drop(config), do: storage_down(config) diff --git a/lib/event_store/storage/lock.ex b/lib/event_store/storage/lock.ex index 0e73b33a..06e19d09 100644 --- a/lib/event_store/storage/lock.ex +++ b/lib/event_store/storage/lock.ex @@ -1,8 +1,6 @@ defmodule EventStore.Storage.Lock do @moduledoc false - require Logger - alias EventStore.Sql.Statements @doc """ From 7a01cde93725b8f9b0d9e18684e7a7169f320f0f Mon Sep 17 00:00:00 2001 From: "@wimwian" Date: Sun, 26 Jul 2026 10:57:37 +0530 Subject: [PATCH 2/4] fix: pattern-match RecordedEvent struct in prepare_events/4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Elixir 1.20's type checker can't prove `recorded_event` (destructured from the {recorded_event, index} tuple produced by Enum.with_index/2) is a %RecordedEvent{} at the point it's used in a struct update: warning: a struct for EventStore.RecordedEvent is expected on struct update map_to_recorded_event/3 always returns %RecordedEvent{}, so this is a type-checker visibility gap, not a real bug — pattern-matching %RecordedEvent{} in the anonymous function head makes the invariant explicit and resolves the warning. (cherry picked from commit a9f3b6e360d9ed7a3f3e9ae9486a88ec2bec4923) Signed-off-by: Yordis Prieto --- lib/event_store/streams/stream.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/event_store/streams/stream.ex b/lib/event_store/streams/stream.ex index 3a161003..22f803cc 100644 --- a/lib/event_store/streams/stream.ex +++ b/lib/event_store/streams/stream.ex @@ -156,7 +156,7 @@ defmodule EventStore.Streams.Stream do events |> Enum.map(&map_to_recorded_event(&1, opts[:created_at_override] || utc_now(), serializer)) |> Enum.with_index(1) - |> Enum.map(fn {recorded_event, index} -> + |> Enum.map(fn {%RecordedEvent{} = recorded_event, index} -> %RecordedEvent{ recorded_event | stream_uuid: stream_uuid, From 7d10c6e311e8500f424c9f01a009635840943d04 Mon Sep 17 00:00:00 2001 From: FinOpsTech Bot Date: Wed, 28 Jan 2026 09:20:18 +0100 Subject: [PATCH 3/4] Trap exit for graceful shutdown In our testsuit we observed the following logs producing noise: `[info] Postgrex.Protocol (#PID<0.867.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.868.0> exited`. They seem to be cause by calling `Application.stop(:eventstore)` at the end of our test case. The root cause appears to be the hard kill that `AdvisoryLocks` experiences without the ability to checkin a currently held `DBConnection`. Trapping exits is sufficient to allow for a normal connection checkin before termination. (cherry picked from commit d4cc6c3fec8c938965f82613e3e63ec307a40bb3) Signed-off-by: Yordis Prieto --- lib/event_store/advisory_locks.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/event_store/advisory_locks.ex b/lib/event_store/advisory_locks.ex index d8033b08..92f556b8 100644 --- a/lib/event_store/advisory_locks.ex +++ b/lib/event_store/advisory_locks.ex @@ -52,6 +52,8 @@ defmodule EventStore.AdvisoryLocks do end def init(%State{} = state) do + Process.flag(:trap_exit, true) + %State{conn: conn} = state {:ok, ref} = MonitoredServer.monitor(conn) From 0cc11a973a69cb822592ea5ef088b6ddd1d20ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Silvan=20B=C3=BCdenbender?= Date: Wed, 28 Jan 2026 10:35:04 +0100 Subject: [PATCH 4/4] Handle EXIT message from non-parent processes (cherry picked from commit d7ce76d46facb372ac057bb0fa74b3c7c5b1b8c1) Signed-off-by: Yordis Prieto --- lib/event_store/advisory_locks.ex | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/event_store/advisory_locks.ex b/lib/event_store/advisory_locks.ex index 92f556b8..8fe9481f 100644 --- a/lib/event_store/advisory_locks.ex +++ b/lib/event_store/advisory_locks.ex @@ -142,6 +142,14 @@ defmodule EventStore.AdvisoryLocks do {:noreply, state} end + def handle_info({:EXIT, _, :normal}, state) do + {:noreply, state} + end + + def handle_info({:EXIT, _from, reason}, state) do + {:stop, reason, state} + end + defp notify_lost_locks(locks, reason) do for {_ref, %Lock{} = lock} <- locks do %Lock{owner: owner, ref: ref} = lock