Skip to content

Conversation

timbussmann
Copy link
Contributor

Who's affected

You might be affected if you are using one of the following transport configurations:

  • RabbitMQ transport
  • Azure transport
  • MSMQ or SQL transport with distributed transactions (DTC) disabled.

and you are using timeouts or deferred messages (e.g. Bus.Defer(...))

Symptoms

When experiencing connectivity issues with the transport there's a chance that a due timeout/deferred message is lost. Therefore the message will never arrive.

What to do if you are affected

We highly recommend to update to the latest patch versions of your NServiceBus and optional persistence and transport packages. For more details see issue #2885

Connects to Particular/NServiceBus#2885

@timbussmann timbussmann changed the title implement IPersistTimeoutsV2 interface [WIP] implement IPersistTimeoutsV2 interface Sep 22, 2015
@timbussmann timbussmann changed the title [WIP] implement IPersistTimeoutsV2 interface implement IPersistTimeoutsV2 interface Sep 23, 2015
@timbussmann
Copy link
Contributor Author

@Particular/nservicebus nhibernate experts please review

@timbussmann timbussmann added this to the 4.5.5 milestone Sep 28, 2015
@ramonsmits
Copy link
Member

As discussed during the review:

  • Normal operation is peek, send, delete. During peek we can do a row lock so that the delete will always succeed. Currently the peek and delete are executed in the same transaction when using connection sharing between sql transport and nhibernate persistence. Maybe this can potentially happen when running with multiple instances are fetching timeouts as these instance are competing on the timeout queue. (ISession.Get<T>(object, LockMode.Upgrade)
  • The entity mapping is duplicate except for one property. Unknown why this is or what behavioral change this will have. Maybe refactor to one mapping due to the number of properties and using object initializer instead of a constructor which can potentially result in missing properties if the object is extended in the future.

@timbussmann
Copy link
Contributor Author

@ramonsmits just had a look at the LockMode.Upgrade when peeking but I get some unwanted behavior in the unit test. If you have two concurrent transactions creating an update lock, can they deadlock each other?

@ramonsmits
Copy link
Member

No, that should not be the case as it then does a SELECT FOR UPDATE (rowlock), that should not result in a deadlock, it can only result in a sequential operation. 2nd transaction will have to wait before the first completes(commit or abort) but the 1st does not have to wait for the 2nd because it already acquired a row write lock.

@timbussmann
Copy link
Contributor Author

@ramonsmits never mind, It seems to be an issue with SQLite, same code works on SQLExpress.

@timbussmann
Copy link
Contributor Author

@ramonsmits please review the latest commit, I changed the code according to your points:

  • using upgrade lock for peek. This should only improve scenarios when using dtc for now, since as we saw, this version doesn't yet support connection sharing. So the only case where that lock may be held until the TryRemove is for ambient transactions.
  • extracted the entity mapping so both Peek and TryRemove behave the same.

@@ -11,7 +11,7 @@ namespace NServiceBus.TimeoutPersisters.NHibernate.Tests
public class When_fetching_timeouts_from_storage : InMemoryDBFixture
{
[Test]
public void Should_return_the_complete_list_of_timeouts()
public void GetNextChunk_should_return_the_complete_list_of_timeouts()
Copy link
Member

Choose a reason for hiding this comment

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

Why the method name change? Test is unaltered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to distinct between GetNextChunk and Peek tests

@timbussmann
Copy link
Contributor Author

@Particular/nservicebus @ramonsmits any further concerns or can we merge this?

@andreasohlund
Copy link
Member

Looks good to me

SzymonPobiega added a commit that referenced this pull request Oct 7, 2015
implement IPersistTimeoutsV2 interface
@SzymonPobiega SzymonPobiega merged commit 70a524a into support-4.5 Oct 7, 2015
@SzymonPobiega SzymonPobiega deleted the hotfix-4.5.5 branch October 7, 2015 12:51
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.

4 participants