Servicebus Message Lock Lost exception RRS feed

  • Question

  • HI there,

    We have a Premium service-bus subscription in Production, the Lock token is expired too sooner and the same message is picked up by other threads of Logic app(I am using Logicapp to process the Message payload), like wise multi threads of Logic apps are picking the same message and trying to process while the first one is still in progress. The Lock Duration for ServiceBus is 5 minutes.

    Please help. we are facing this issue and lot many Logic apps are executed unnecessarily. 


    • Edited by Sharath12345 Wednesday, December 18, 2019 7:11 PM
    Wednesday, December 18, 2019 7:08 PM

All replies

  • Message locking is done when doing ‘PeekLock’ receive. The lock itself held in memory and is volatile. When calling Complete() to indicate completion of message processing you get a MessageLockLostException. This can happen for a few reason: I am describing the most common one.

    1. The time between calling Receive() and calling Complete() has exceeded the lock duration. For most customers this is the most likely cause and whose message processing code communicates to other service and the latency of those service increases causing the MessageLockLostException.

    MessageLockLostException indicates that it has taken longer than the defined LockDuration to process the message. I would recommend to log execution time and analyze how long did it take when the exception is thrown.

    Side note: TimeToLive and MaxDeliveryCount are not related to this issue

    Monday, December 23, 2019 5:28 AM
  • Hi DixitArora-MSFT,

    Thanks for responding.

    My problem is: We have set the LockDuration to 5 minutes, but unfortunately it is throwing the error, I am sharing below images, so you know the issue. I have only ONE Api call which is made and that call itself will never take more than a second(or couple of seconds max). I am seeing this locklost exception very frequently these days. Out of every 100 LogicApp runs(PeekLock on messages) we see at-least one or two failing.   

    The side affect of this behavior is: As the Lock is no more on the Message. The next available session is picked and executed( that the same message is picked by multiple logicapp threads and unnecessary run are getting executed).

    Subscription Lock Duration:


    LogicApp execution(first action of logic app, getting the message from TopicSubscription with PEEKLock): (I erased the subscription name)

    LogicApp execution(After the API call is made, I am calling Complete the Message):  (I erased the subscription name)


    LogicApp execution(The same action showing the Lock Lost exception):

    Error message:  "message": "Failed to complete the message with the lock token '97fec634-7785-4c14-87e6-d05e285be24e'. The lock on the message has been lost.\r\nclientRequestId: xxxxxxxxxx(removed the real one)xxxxxxxxxx",

    This is becoming severe issue in PROD and there is nothing to change(no custom code we wrote) as we are using the standard actions provided by Microsoft LogicApp and ServiceBus.

    Please help.

    Monday, December 23, 2019 6:51 AM
  • Hi Sharath12345,

    As it is a Production issue so It might be better to open a support case to troubleshoot this issue together with a service engineer who has deeper insight to your environment. 

    Does your subscription carry a support plan? If not, just let us know.

    Monday, December 23, 2019 9:47 AM
  • Hi DixitArora,

    Thanks for the response. Yes we have a support plan, we raised a ticket and support person is helping on the issue. 

    Friday, December 27, 2019 6:19 PM
  • Hi Sharath12345,

    Can you please share the support case number so that we can track it.

    Monday, December 30, 2019 4:24 AM