Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chat: obtain better dm ordering guarantees #3883

Merged
merged 1 commit into from
Sep 5, 2024
Merged

chat: obtain better dm ordering guarantees #3883

merged 1 commit into from
Sep 5, 2024

Conversation

Fang-
Copy link
Member

@Fang- Fang- commented Sep 4, 2024

Ames guarantees message ordering only within the same flow. Using a different duct stack creates a new flow. The wire used by the agent shows up in the duct stack for the messages it sends.

Previously, we were putting DM message identifiers into the poke wire, resulting in a unique flow for each message. We need this because when we eventually get a (n)ack for the poke, we may need to correlate that with the sent message, to handle failure cases gracefully (and potentially to track delivery status if we ever want it).

Recently, ~palfun has been under load, spending lots of time processing whatever, and dropping many packets in the process. One of the symptoms this resulted in was receiving DMs out of order, sometimes with egregious delays between them. My working theory here is that, because every flow has its own retry timer, and delivery rates were low, "later" flows might retry and/or deliver their messages before "earlier" flows.

To regain the ordering guarantees ames is able to give us, we now use a static wire for DM message sending, and lean on the ordering guarantee that gives us by keeping a queue of outgoing messages that are pending delivery.

This change only applies to ship-to-ship DMs. Channels already uses a static wire (+ca-send-command), so should be unaffected by this issue. Group DMs also put ids into the wire (+act:cu-pass), and may benefit from a similar patch, but also has a more convoluted networking model to account for. @arthyn we may want to sit down and do a quick pass over the codebase for similar issues.

Tested and confirmed locally that before this change, every message created a new flow, and that after the change this is no longer the case. Have hit both happy and nack codepaths, and the latter retries like it used to. Will do some more extensive testing to try and hit the exact case that bit ~palfun, but should be ready for review already.

Ames guarantees message ordering only within the same flow. Using a
different duct stack creates a new flow. The wire used by the agent
shows up in the duct stack for the messages it sends.

Previously, we were putting DM message identifiers into the poke wire,
resulting in a unique flow for each message. We need this because when
we eventually get a (n)ack for the poke, we may need to correlate that
with the sent message, to handle failure cases gracefully (and
potentially to track delivery status if we ever want it).

Recently, ~palfun has been under load, spending lots of time processing
whatever, and dropping many packets in the process. One of the symptoms
this resulted in was receiving DMs out of order, sometimes with
egregious delays between them. My working theory here is that, because
every flow has its own retry timer, and delivery rates were low, "later"
flows might retry and/or deliver their messages before "earlier" flows.

To regain the ordering guarantees ames is able to give us, we now use a
static wire for DM message sending, and lean on the ordering guarantee
that gives us by keeping a queue of outgoing messages that are pending
delivery.

This change only applies to ship-to-ship DMs. Channels already uses a
static wire (+ca-send-command), so should be unaffected by this issue.
Group DMs also put ids into the wire (+act:cu-pass), and may benefit
from a similar patch, but also has a more convoluted networking model to
account for. @arthyn we may want to sit down and do a quick pass over
the codebase for similar issues.

Tested and confirmed locally that before this change, every message
created a new flow, and that after the change this is no longer the
case. Have hit both happy and nack codepaths, and the latter retries
like it used to.
@Fang- Fang- requested a review from arthyn September 4, 2024 12:30
@Fang- Fang- added bug Something isn't working chat labels Sep 4, 2024
Copy link
Member

@arthyn arthyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me!

@Fang-
Copy link
Member Author

Fang- commented Sep 5, 2024

Successfully reproduced the issue and confirmed the fix. Let's get it!

@Fang- Fang- merged commit a099e18 into develop Sep 5, 2024
1 check passed
@Fang- Fang- deleted the m/dm-order branch September 5, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants