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

Fix C# connection to correctly mark message as sent #3072

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

pepone
Copy link
Member

@pepone pepone commented Nov 5, 2024

This PR fixes C# Connection to correctly mark messages as sent, once that startWrite handles the complete buffer.

This bug was introduced in #2270, probably and oversight because of the subtle difference between C# and C++ startWrite calls.

Here to warrantee at-most once semantics we have to mark the request as sent, once that startWrite is has consumed the complete buffer.

For C++ this is the return value of startWrite, for C# the return value is whether or not the write call completed synchronously and there is a separate out parameter that indicates whether or not the call consumed the complete buffer.

This must be back ported to 3.7, but the issue doesn't affect 3.7.10.

Fixes #2722

Copy link
Member

@bernardnormier bernardnormier left a comment

Choose a reason for hiding this comment

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

Looks good.

_writeStream.getBuffer(),
completedCallback,
this,
out messageWritten);
Copy link
Member

Choose a reason for hiding this comment

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

It's not clear to me why the C# startWrite has such a complicated signature compared to the C++ startWrite. In C++, we don't have this "completedSynchronously" return value.

In any case, assuming this complicated C# API is warranted, we should:

  • rename the last parameter of Transceiver.startWrite. Having return value = completedSynchronously and out parameter = completed is too confusing.
  • consider returning a tuple (does this work with the old C# version we use on 3.7?)
  • name the "messageWritten" parameter => messageFullyWritten
  • add a real doc-comment on Transceiver.startWrite

Copy link
Member Author

@pepone pepone Nov 6, 2024

Choose a reason for hiding this comment

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

In any case, assuming this complicated C# API is warranted, we should:

Can we do that in a separate PR?

consider returning a tuple (does this work with the old C# version we use on 3.7?)

It does not work with .NET 4.5

Copy link
Member

@bernardnormier bernardnormier Nov 6, 2024

Choose a reason for hiding this comment

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

Yes, this can wait until a follow-up PR.

out messageWritten);
// If the startWrite call consumed the complete buffer, we assume the message is sent now for
// at-most-once semantics.
if (messageWritten && _sendStreams.Count > 0)
Copy link
Member

Choose a reason for hiding this comment

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

(Not from this PR)
Do you know when we can reach this point with _sendStreams.Count == 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems StartWrite is some times called with a 0 buffer size just to invoke the completion callback. It is not clear why we do it that way, and cannot call it from the finishAsync.

@pepone pepone merged commit b3e5b20 into zeroc-ice:main Nov 6, 2024
19 checks passed
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.

csharp/Ice/retry failure (ubuntu)
3 participants