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

Work on ConsumerController deadlock #7092

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented Feb 9, 2024

Changes

Fixes #7088 - work in progress.

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Latest dev Benchmarks

Include data from the relevant benchmark prior to this change here.

This PR's Benchmarks

Include data from after this change here.

@Aaronontheweb Aaronontheweb added the akka-delivery Akka.Delivery APIs label Feb 9, 2024
@Aaronontheweb Aaronontheweb changed the title added XML-DOC comments to current ConsumerController.Settings Work on ConsumerController deadlock Feb 9, 2024
@Arkatufus Arkatufus marked this pull request as ready for review February 14, 2024 22:11
Copy link
Contributor

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

Self-review

/// When disabled, the <see cref="ConsumerController"/> will discard any <c>Retry</c> messages when it is
/// waiting for a message confirmation.
/// </summary>
public bool RetryConfirmation { get; init; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Added new RetryConfirmation settings

Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM

Comment on lines +389 to +390
if (!Settings.RetryConfirmation)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Only retry the delivery if RetryConfirmation is set to true

Comment on lines +393 to +399
ReceiveRetry(() =>
{
_log.Debug("Retry sending SequencedMessage [{0}].", sequencedMessage.SeqNr);
CurrentState.Consumer.Tell(new Delivery<T>(sequencedMessage.Message.Message!, Context.Self,
sequencedMessage.ProducerId, sequencedMessage.SeqNr));
Become(() => WaitingForConfirmation(sequencedMessage));
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Retry logic

@@ -664,6 +664,8 @@ akka {
# kept in memory in the `ProducerController` until they have been
# confirmed, but the drawback is that lost messages will not be delivered.
only-flow-control = false

retry-confirmation = false
Copy link
Contributor

Choose a reason for hiding this comment

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

RetryConfirmation is false by default

Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM

Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

LGTM but left some questions

@@ -664,6 +664,8 @@ akka {
# kept in memory in the `ProducerController` until they have been
# confirmed, but the drawback is that lost messages will not be delivered.
only-flow-control = false

retry-confirmation = false
Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM

@@ -672,4 +673,26 @@ public async Task ConsumerController_can_process_zero_length_Chunk()
consumerController.Tell(seqMessages1.First());
(await consumerProbe.ExpectMsgAsync<ConsumerController.Delivery<ZeroLengthSerializer.TestMsg>>()).Message.Should().Be(ZeroLengthSerializer.TestMsg.Instance);
}

[Fact]
public async Task ConsumerController_must_not_resend_Delivery()
Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM

public static readonly Config Config = @"
akka.reliable-delivery.consumer-controller {
flow-control-window = 20
resend-interval-min = 1s
Copy link
Member Author

Choose a reason for hiding this comment

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

Might want to lower this given that you're waiting for up to 1.5 seconds - just to provide a bigger window in the event of racy tests

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, will do

/// When disabled, the <see cref="ConsumerController"/> will discard any <c>Retry</c> messages when it is
/// waiting for a message confirmation.
/// </summary>
public bool RetryConfirmation { get; init; }
Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM

_log.Debug("Retry sending SequencedMessage [{0}].", sequencedMessage.SeqNr);
CurrentState.Consumer.Tell(new Delivery<T>(sequencedMessage.Message.Message!, Context.Self,
sequencedMessage.ProducerId, sequencedMessage.SeqNr));
Become(() => WaitingForConfirmation(sequencedMessage));
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need to do a Become again here? Aren't we already in this state?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's no harm in doing it, we might as well have the code to explicitly show which state we're transitioning to.

@Aaronontheweb Aaronontheweb merged commit 1c8ffc3 into akkadotnet:dev Feb 16, 2024
9 of 12 checks passed
@Aaronontheweb Aaronontheweb deleted the fix-7088-ConsumerController-deadlock branch February 16, 2024 14:14
@Aaronontheweb
Copy link
Member Author

@Arkatufus merged - we'll need a separate PR to add some documentation for this to the Akka.Delivery page on the website

Arkatufus added a commit to Arkatufus/akka.net that referenced this pull request Feb 28, 2024
Aaronontheweb pushed a commit that referenced this pull request Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
akka-delivery Akka.Delivery APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConsumerController is Deadlocked in WaitingForConfirmation Status
2 participants