From d4fd8187b330f5f78343e5f130e290c230646389 Mon Sep 17 00:00:00 2001 From: urmastalimaa Date: Fri, 14 Jun 2024 12:16:23 +0300 Subject: [PATCH 1/3] Guard against undefined partition worker pid I've observed a data race when starting a consumer from within another consumer (using co-partitioned topics), where the call to `get_partition_worker` fails due to badarg in `is_process_alive`. It seems that 1f2290b ("Verify partition worker process is alive.", 2022-05-19) already tried to resolve the data race, but did not consider the possibility that the lookup returns `undefined`. Example exit report from Elixir logger: ``` Last message: {:EXIT, #PID<0.2613.0>, {:badarg, [{:erlang, :is_process_alive, [:undefined], [error_info: %{module: :erl_erts_errors}]}, {:brod_client, :get_partition_worker, 2, [file: ~c"/app/deps/brod/src/brod_client.erl", line: 496]}, ...MyCallChain]}} ``` --- src/brod_client.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brod_client.erl b/src/brod_client.erl index 66f52268..8f4aad24 100644 --- a/src/brod_client.erl +++ b/src/brod_client.erl @@ -493,7 +493,7 @@ get_partition_worker(ClientId, Key) when is_atom(ClientId) -> %% If the worker process is returned form ets, %% but it is not alive then there must be %% an in-flight worker deregistration request. - case is_process_alive(Pid) of + case is_pid(Pid) andalso is_process_alive(Pid) of true -> {ok, Pid}; false -> get_partition_worker_with_ets(ClientId, Key) end; From 4e88e1f242b749da1eaf847a844e7b4d11e6b943 Mon Sep 17 00:00:00 2001 From: urmastalimaa Date: Fri, 14 Jun 2024 12:56:10 +0300 Subject: [PATCH 2/3] Add changelog for version 3.19.1 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c73416cf..3bfdb2c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Made brod-cli to work on OTP 26. [PR#582](https://github.com/kafka4beam/brod/pull/582) - `--ssl` option is now mandatory if TLS is to be used (previously it can be derived from `--cacertfile` option) - TLS version defaults to 1.2, added `--ssl-versions` to support explictly setting TLS 1.3 + - Support building on OTP 27 [PR#585](https://github.com/kafka4beam/brod/pull/585) + Also fixed rebar.lock for dependency `kafka_protocol-4.1.5` + - Guard against crashes in `brod_client:get_consumer/3` [PR#581](https://github.com/kafka4beam/brod/pull/581) - 3.19.0 - Forward unhandled messages in topic/group consumer processes to handle_info/2 callbacks From afe4dfb62a82cbe624bdd1d0f449d009b3dd1573 Mon Sep 17 00:00:00 2001 From: zmstone Date: Wed, 26 Jun 2024 12:05:21 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bfdb2c0..ab00c8c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - TLS version defaults to 1.2, added `--ssl-versions` to support explictly setting TLS 1.3 - Support building on OTP 27 [PR#585](https://github.com/kafka4beam/brod/pull/585) Also fixed rebar.lock for dependency `kafka_protocol-4.1.5` - - Guard against crashes in `brod_client:get_consumer/3` [PR#581](https://github.com/kafka4beam/brod/pull/581) + - Guard against crashes in `brod_client:get_consumer/3` [PR#587](https://github.com/kafka4beam/brod/pull/587) (originally [PR#581](https://github.com/kafka4beam/brod/pull/581)) - 3.19.0 - Forward unhandled messages in topic/group consumer processes to handle_info/2 callbacks