Skip to content

rabbit_db: Fix handling of async m2k puts (backport #15480)#15522

Merged
dumbbell merged 1 commit intov4.2.xfrom
mergify/bp/v4.2.x/pr-15480
Feb 20, 2026
Merged

rabbit_db: Fix handling of async m2k puts (backport #15480)#15522
dumbbell merged 1 commit intov4.2.xfrom
mergify/bp/v4.2.x/pr-15480

Conversation

@mergify
Copy link
Copy Markdown

@mergify mergify bot commented Feb 20, 2026

Why

Several rabbit_db_*_m2k_converter modules use async puts to Khepri to parallelize writes and make them faster. This is handled by the rabbit_db_m2k_converter:with_correlation_id/2 function.

Ra will send back a Ra event message for each async write to reply with the result of the write. The problem is that the code behind with_correlation_id/2 has a logic issue: it only consumes 1 Ra event every 64 async writes. It will consume all of them at the end of the overall, but meeawhile, messages will accumulate. If there are a lot of Mnesia records to copy, this can fill the process mailbox and slow it down significantly.

How

The logic is changed to regularily consume all messages in the mailbox with a timeout of 0. Only at the end, remaining messages are consumed with an infinity timeout because we know how many messages we are expecting (the actual timeout is handled by the write itself).


This is an automatic backport of pull request #15480 done by Mergify.

[Why]
Several `rabbit_db_*_m2k_converter` modules use async puts to Khepri to
parallelize writes and make them faster. This is handled by the
`rabbit_db_m2k_converter:with_correlation_id/2` function.

Ra will send back a Ra event message for each async write to reply with
the result of the write. The problem is that the code behind
`with_correlation_id/2` has a logic issue: it only consumes 1 Ra event
every 64 async writes. It will consume all of them at the end of the
overall, but meeawhile, messages will accumulate. If there are a lot of
Mnesia records to copy, this can fill the process mailbox and slow it
down significantly.

[How]
The logic is changed to regularily consume all messages in the mailbox
with a timeout of 0. Only at the end, remaining messages are consumed
with an infinity timeout because we know how many messages we are
expecting (the actual timeout is handled by the write itself).

While here, delete debug log messages logged for each async puts. With a
significant number of puts, this noticably slows down the process.

(cherry picked from commit c6415de)
@dumbbell dumbbell marked this pull request as draft February 20, 2026 10:51
@dumbbell dumbbell marked this pull request as ready for review February 20, 2026 11:05
@dumbbell dumbbell merged commit 92785aa into v4.2.x Feb 20, 2026
291 checks passed
@dumbbell dumbbell deleted the mergify/bp/v4.2.x/pr-15480 branch February 20, 2026 11:05
@dumbbell dumbbell added this to the 4.2.5 milestone Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant