[Bug Fix] NServiceBus Azure Storage Persister

50 views
Skip to first unread message

Britt King

unread,
Apr 13, 2016, 8:44:30 AM4/13/16
to Particular Software

Hi everyone,


We've just released NServiceBus.Azure 6.2.4.


Fixed bugs:


How to know if you are affected

This bug will affect an endpoint under the following conditions:

  • the endpoint references NServiceBus Version 5 or lower
  • the endpoint references NServiceBus.Azure Version 6.2.3 or lower
  • the endpoint uses AzureStoragePersitence for it's persistence
  • the endpoint's concurrency is set to > 1

Should you upgrade immediately?

If you are using Azure Storage Persistence and your system has sagas then you should upgrade immediately.


How to upgrade

Upgrade instructions to resolve this bug are available at the following upgrade documentation page http://docs.particular.net/nservicebus/upgrades/asp-saga-deduplication


The patching instructions will guide you through the upgrade process but don't hesitate to contact sup...@particular.net if you have any questions.


Regards,


-Britt

Geert Depickere

unread,
Apr 14, 2016, 3:19:13 AM4/14/16
to Particular Software
Compared to this post, the upgrade documentation contains an additional condition:
  • the endpoint contains a saga which has more than one IAmStartedBy<T>
I only have a single starting message type so I guess I don't have to upgrade immediately?

On the other hand, even with a single starting message type I still think there can be a concurrency problem:  

Example: 
In our IoT solution the user can configure rules that inform him by email of certain status changes on the monitored devices. He can also configure the rules to get reminder emails while the device remains in that state. I use saga's to orchestrate the rules. Separate saga instances are started per device/rule combination. There can be multiple triggers for the same rule (e.g. send email when temperature1 > 50 OR temperature2 > 45. For the same device, both temperatures can reach their theshold at the same time (concurrently). As I have my endpoint concurrency = 5, I think the same saga instance could be started concurrently resulting in 2 saga instances. 

Or am I safe because I have a rowversion field in my saga data? (see code below).

Please comment.


    // Note about NHibernate concurrency settings
    //
    // - NHibernate will use the Version field attributed with [RowVersion] for optimistic concurrency checking
    // - By default, starting from version 4.1.0 of the NHibernate saga persister, an additional pessimistic concurrency control was added. 
    //   This however locks the saga status row till the end of the transaction. To disable this pessimistic concurrency control we added
    //   [LockMode(LockModes.Read)], resulting in a pure optimistic concurrency strategy (with retries).
    //
    [LockMode(LockModes.Read)]
    public class RuleActionManagerStatus : IContainSagaData
    {
        #region IContainSagaData implementation

        public virtual Guid Id { get; set; }
        public virtual string OriginalMessageId { get; set; }
        public virtual string Originator { get; set; }

        #endregion

        [RowVersion]
        public virtual byte[] Version { get; set; }

        private string _sagaKey;

        [Unique]
        public virtual string SagaKey
        {
            get
            {
                _sagaKey = CreateSagaKey(RuleId, DeviceId);
                return _sagaKey;
            }
            set
            {
                _sagaKey = value;
            }
        }

        public static string CreateSagaKey(string ruleId, string assetId)
        {
            return string.Format("{0}/{1}", ruleId, assetId);
        }

        public virtual string RuleId { get; set; }
        public virtual string DeviceId { get; set; }
        public virtual string RuleName { get; set; } // Only purpose = make debugging easier...

        // Note:
        // By default, NHibernate would create database columns of type nvarchar(255).
        // However, the lenght of these strings can be more than 255 characters.
        // To force NHibernate to create these database columns as nvarchar(max) a hbm.xml file
        // has to be created for this type with Build action = "embedded resource".
        // Also, in that file, don't forget to make the SagaKey field unique=true!!!

        public virtual string InvokingTriggerAsString { get; set; }
        public virtual string InvokingDataExpressionAsString { get; set; }

        public virtual bool InProgress { get; set; }
        public virtual int DelayInSeconds { get; set; }
        public virtual int RepetitionIntervalInSeconds { get; set; }
        public virtual int MaximumNumberOfRepetitions { get; set; }
        public virtual int ExecutionCounter { get; set; }
    }

szymon...@particular.net

unread,
Apr 14, 2016, 5:17:21 AM4/14/16
to Particular Software
Hi Geert,
thank you for posting the comment. The fix has been provided for the Azure Storage Persistence only. I can see that some comments in your code refer to NHibernate as well as the LockMode attribute. Could you clarify which persistence do you use?

Regards
Szymon Kulec

The patching instructions will guide you through the upgrade process but don't hesitate to contact us if you have any questions.


Regards,


-Britt

Geert Depickere

unread,
Apr 14, 2016, 9:03:18 AM4/14/16
to Particular Software
I am using Sql Azure storage for my saga data, so I now realize that this bugfix release is not related to that. Thanks for pointing that out.

Geert.

On Wednesday, April 13, 2016 at 2:44:30 PM UTC+2, Britt King wrote:
Reply all
Reply to author
Forward
0 new messages