Significant increasing MessageLockLost error on RenewMessageLock operation.

Junjie Zhang (NCM) 0 Reputation points Microsoft Employee
2025-12-19T05:13:27.6366667+00:00

Start time: 12/17/2025 04:00 AM (UTC +10:00)

End time: Still ongoing

Our service uses this queue for a long time and recently we find there have significant increasing RenewMessageLock failed errors.

We observed lots of failures trying to renew message, this could be observed from both our service log and Service Bus internal logs.

And we already checked our renew time didn't exceeded the queue's Lock Duration, such for message (tracking id: 33b594d7-172b-43fa-a341-0fd7ebffb25d_B21):

12/19/2025, 2:36:36.719258 AM -- Last round renews message start. 12/19/2025, 2:36:36.766183 AM -- Last round renews message succussed. 12/19/2025, 2:38:59.695319 AM -- Renew message start. 12/19/2025, 2:38:59.695319 AM -- Renew message failed.

Please check the failure reason for the recent message renews.

Error stack (I only post the common error stack and trace id here to avoid any sensitive information):


Azure.Messaging.ServiceBus.ServiceBusException: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue. For more information please see https://aka.ms/ServiceBusExceptions . Reference:85b59091-3f5b-421c-8afb-b7c65b7a3dab, TrackingId:33b594d7-172b-43fa-a341-0fd7ebffb25d_B21, SystemTracker:xxx, Timestamp:2025-12-19T02:38:59 (MessageLockLost). For troubleshooting information, see https://aka.ms/azsdk/net/servicebus/exceptions/troubleshoot.
   at Azure.Messaging.ServiceBus.Amqp.AmqpReceiver.<RenewMessageLockInternalAsync>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Azure.Messaging.ServiceBus.Amqp.AmqpReceiver.<>c.<<RenewMessageLockAsync>b__64_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<RunOperation>d__24`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<RunOperation>d__24`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Azure.Messaging.ServiceBus.Amqp.AmqpReceiver.<RenewMessageLockAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Azure.Messaging.ServiceBus.ServiceBusReceiver.<RenewMessageLockAsync>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Azure.Messaging.ServiceBus.ServiceBusReceiver.<RenewMessageLockAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-19T05:13:40.33+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The MessageLockLost error you are encountering during the RenewMessageLock operation indicates that the lock on the message is no longer valid. This can happen for a few reasons:

    1. Lock Expiration: If the message lock is not renewed before it expires, the Service Bus broker releases the lock, making the message available for other receivers. Ensure that your lock renewals are happening within the lock duration set for the queue.
    2. Message Already Removed: If the message has already been processed and removed from the queue by another receiver, any attempt to renew the lock will fail.
    3. Lock Renew Task: If your application processing time exceeds the configured lock renew task duration, and if the renew task is disabled, this can lead to lock expiration. By default, the lock renew task runs for 5 minutes, but this can be adjusted using ServiceBusReceiverClientBuilder.maxAutoLockRenewDuration(Duration).
    4. Prefetch Feature: If the Prefetch feature is enabled, messages are retrieved and stored in an in-memory buffer without extending their locks. If processing takes too long, the locks may expire while in the prefetch buffer.

    To troubleshoot further, you can:

    • Check the processing time of your messages to ensure they are within the lock duration.
    • Review the configuration of your lock renew task and consider enabling it if it is currently disabled.
    • Monitor the usage of the Prefetch feature and adjust it according to your processing needs.

    For more detailed troubleshooting, refer to the provided links in the error message for guidance on handling ServiceBusException errors.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.