make sure to unset batch_key when connection is removed from batch#48311
Merged
make sure to unset batch_key when connection is removed from batch#48311
Conversation
9e808ef to
6258d7d
Compare
6258d7d to
0f5ebb6
Compare
serra-fastly
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For bulk IPC communication, Pushpin will address multiple connections in the same packet. For example, if a component needs to send keep-alive packets for 100 connections with a peer, then it will try to send just 1 keep-alive packet to that peer that is addressed to all 100 connections.
In connmgr, the
Batchtype helps sort out how to do this. When it is time to perform such bulk communications, connections are added to the batch withBatch::add, even if the connections are with different peers. Then, peer-specific "groups" of connections can be extracted withBatch::take_groupfor easily sending to them.When a
ConnectionItemis added to a batch, itsbatch_keyfield will be set to the return value ofBatch::add. This value is kept around so if the connection is dropped it can remove itself from the batch withBatch::remove. Importantly, when the connection has been removed from the batch viaBatch::take_group, this field needs to be set toNone. In some very rare cases we might fail to do this, which means when the connection is eventually dropped it will try to remove itself from a batch that it's not in. This will result in a panic inList::remove().Those rare cases we fail to unset
batch_keyare:take_groupreturnsNone. In this case, the connection will still be removed from the batch without this being communicated to the caller, and so the caller doesn't know to unset thebatch_key.take_groupreturns and when it unsetsbatch_key.This PR makes the batch API a little more clear and ensures
batch_keyis always set toNonefor connections removed bytake_group.