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

InMemory saga persister creates duplicate saga instances #4182

Merged
merged 2 commits into from Oct 4, 2016

Conversation

danielmarbach
Copy link
Contributor

@danielmarbach danielmarbach commented Oct 3, 2016

Who's affected

All users using InMemory saga persister that have messages concurrently trying to start the same saga instance on an endpoint with concurrency set to a value above the default of 1.

Symptoms

Two saga instances are created which leads to incorrect business behavior.

Solution

v5 supports multiple correlation properties. So here the lock will be taken on the FullName of the saga entity type

@danielmarbach danielmarbach changed the title InMemorySagaPersistence handles concurrently started sagas properly InMemory saga persister creates duplicate saga instances Oct 3, 2016
@danielmarbach danielmarbach added this to the 5.2.17 milestone Oct 3, 2016
Copy link
Member

@andreasohlund andreasohlund left a comment

Choose a reason for hiding this comment

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

Just a few nitpicks

}
}

[Serializable]
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: We don't need the [Serializable]

public string SomeId { get; set; }
}

[Serializable]
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: We don't need the [Serializable]

public string SomeId { get; set; }
}

[Serializable]
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: We don't need the [Serializable]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remember this is v5. It uses it consistently

Copy link
Member

Choose a reason for hiding this comment

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

Not a 100% https://github.com/Particular/NServiceBus/blob/master/src/NServiceBus.AcceptanceTests/Audit/When_a_replymessage_is_audited.cs#L112 and there's probably more. But as I said nitpick, I'll make sure we remove them for v6.1

@danielmarbach
Copy link
Contributor Author

@Particular/nservicebus-maintainers please review. In order to keep it consistent with v5 behavior I'm calling Save in the update method. v6 behaves differently btw. In v6 Update does not revalidate the correlation properties. Is this something we need to address (to be honest I got confused while looking at the tests and the intended behavior)?

@andreasohlund
Copy link
Member

In v6 Update does not revalidate the correlation properties. Is this something we need to address (to be honest I got confused while looking at the tests and the intended behavior)?

V6 won't let you change the correlation property. I'd say we leave as is for v5?

where
(s.Value.SagaEntity.GetType() == saga.GetType() && (s.Key != saga.Id))
select s.Value;
if (sagaMetaData.CorrelationProperties.Count == 0) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's avoid the if short from

{
if (storedSaga.Value.SagaData.GetType() != sagaType || (storedSaga.Key == saga.Id)) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's avoid the if short from

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was used in other parts in this file as well that's why I kept it consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

not considering this as a blocker, but I don't think consistency on this brings any value in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course it does, at least in the same file the same consistent code style should be used. When I port back into existing code I try to stay consistent with what is there from a style perspective. Applying new formatting rules doesn't make much sense either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you feel strongly about it @timbussmann feel free to apply your desired style changes while merging

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@timbussmann I applied formatting as a separate commit just for you ❤️

Copy link
Contributor

Choose a reason for hiding this comment

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

💃

@andreasohlund
Copy link
Member

@timbussmann please merge if you're happy with the changes

@timbussmann timbussmann merged commit f64678f into hotfix-5.2.17 Oct 4, 2016
@timbussmann timbussmann deleted the inmemory-saga-persistence branch October 4, 2016 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants