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

Test that reconnect doesn't drop partially sent messages #360

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

caleblloyd
Copy link
Collaborator

Add a test that checks that client-side reconnects don't drop partially sent messages out of the send buffer

@caleblloyd caleblloyd requested a review from mtmk January 26, 2024 16:01
@caleblloyd caleblloyd mentioned this pull request Jan 26, 2024
Signed-off-by: Caleb Lloyd <[email protected]>
@caleblloyd
Copy link
Collaborator Author

Interesting - got a dropped message in this test run

Copy link
Collaborator

@mtmk mtmk left a comment

Choose a reason for hiding this comment

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

LGTM

src/NATS.Client.Core/NatsConnection.cs Show resolved Hide resolved
@mtmk
Copy link
Collaborator

mtmk commented Jan 26, 2024

Interesting - got a dropped message in this test run

I'm also getting it sometimes locally:

Expected: 1278
Actual:   1274

Also copied it to a 2.0.x codebase, fails with 0 actual!

Edit: the new branch is a bit better:

Expected: 5298
Actual:   5252

@caleblloyd
Copy link
Collaborator Author

I'm also getting it sometimes locally

Do you think we should put a range in then, to prevent it from being a flapper? With an Issue to follow-up on it?

@mtmk
Copy link
Collaborator

mtmk commented Jan 28, 2024

I'm also getting it sometimes locally

Do you think we should put a range in then, to prevent it from being a flapper? With an Issue to follow-up on it?

I think that's reasonable. Feel free to merge when you're happy with it.

Signed-off-by: Caleb Lloyd <[email protected]>
@caleblloyd
Copy link
Collaborator Author

Great, I've adapted the test to check for <= 1% loss. added my theory as to why there may be loss in the comments:

        // some messages may still be lost, as socket could have been disconnected
        // after socket.WriteAsync returned, but before OS sent
        // check to ensure that the loss was < 1%

If that is indeed where the loss is occurring, I think it is acceptable. Because this loss would occur anyways if we didn't do any buffering at all.

@caleblloyd caleblloyd merged commit ed1dca8 into main Jan 30, 2024
10 checks passed
@caleblloyd caleblloyd deleted the partially-sent-msgs branch January 30, 2024 16:08
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.

2 participants