Skip to content

Handle :EXIT messages in ingestion WriteBuffer#6454

Open
SAY-5 wants to merge 3 commits into
plausible:masterfrom
SAY-5:fix-writebuffer-exit-trap
Open

Handle :EXIT messages in ingestion WriteBuffer#6454
SAY-5 wants to merge 3 commits into
plausible:masterfrom
SAY-5:fix-writebuffer-exit-trap

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 18, 2026

Copy link
Copy Markdown

Changes

Plausible.Ingestion.WriteBuffer calls Process.flag(:trap_exit, true) so terminate/2 can flush the buffer on shutdown, but handle_info/2 only matched :tick. When a linked port or process (the ClickHouse connection socket) exits, the GenServer receives {:EXIT, port, :normal} and crashes with a FunctionClauseError, then restarts. This adds a handle_info/2 clause that ignores :EXIT messages so the buffer keeps running. Fixes #6382.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@CLAassistant

CLAassistant commented Jun 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@aerosol

aerosol commented Jun 29, 2026

Copy link
Copy Markdown
Member

Thanks for your contribution. With regards to the test, it seems a bit pointless to send a message to an artificially spawned buffer - you could do that against the primary buffer as well, since nothing is expected to happen - except no crash. You could experiment with triggering sending the actual EXIT message via Process.exit if you like the test to be more meaningful.

But the PR states that this is ClickHouse socket dying - in which case terminate will try to flush with a dead connection, which may lead to another crash, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants