MQ_ERROR_SHARING_VIOLATION if Dependent Client Terminates Connection (304395)



The information in this article applies to:

  • Microsoft Message Queuing 2.0

This article was previously published under Q304395

SYMPTOMS

When an application attempts to open a queue for receive access, MQ_ERROR_SHARING_VIOLATION may be returned.

CAUSE

Dependent clients use remote procedure call (RPC) to peek or receive from queues on the hosting server. When dependent clients terminate abruptly and leave the RPC connection intact, that RPC connection may not be reported as lost to MSMQ on the hosting server for up to two hours. If the queue was opened with MQ_DENY_RECEIVE_SHARE, no application can open that queue until the timeout occurs and the queue reference count is decremented.

RESOLUTION

To resolve this problem, obtain the latest service pack for Windows 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

260910 How to Obtain the Latest Windows 2000 Service Pack

The English version of this fix should have the following file attributes or later:
   Date           Time    Version    Size       File name     
   --------------------------------------------------------
   Jul-26-2001   23:38  5.0.0.720    273KB  Mq1repl.dll
   May-29-2001   14:22  5.0.0.720     14KB  Mq1sync.dll
   May-29-2001   14:22  5.0.0.735     70KB  Mqac.sys
   Jul-26-2001   23:38  5.0.0.735    210KB  Mqads.dll
   May-29-2001   14:23  5.0.0.720     22KB  Mqbkup.exe
   Jul-26-2001   23:38  5.0.0.720     29KB  Mqcertui.dll
   Jul-26-2001   23:38  5.0.0.720     49KB  Mqclus.dll
   Jul-26-2001   23:38  5.0.0.720     30KB  Mqdbodbc.dll
   Jul-26-2001   23:38  5.0.0.720     74KB  Mqdscli.dll
   Jul-26-2001   23:38  5.0.0.735     41KB  Mqdssrv.dll
   May-29-2001   14:23  5.0.0.720     96KB  Mqmig.exe
   Jul-26-2001   23:38  5.0.0.720    258KB  Mqmigrat.dll
   Jul-26-2001   23:38  5.0.0.720    219KB  Mqoa.dll
   Jul-26-2001   23:38  5.0.0.720      8KB  Mqperf.dll
   Jul-26-2001   23:38  5.0.0.737    409KB  Mqqm.dll
   Jul-26-2001   23:38  5.0.0.720      9KB  Mqrperf.dll
   Jul-26-2001   23:38  5.0.0.737     90KB  Mqrt.dll
   Jul-26-2001   23:38  5.0.0.720     69KB  Mqsec.dll
   Jul-26-2001   23:38  5.0.0.720    391KB  Mqsnap.dll
   May-29-2001   14:23  5.0.0.720     14KB  Mqsvc.exe
   Jul-26-2001   23:38  5.0.0.720     24KB  Mqupgrd.dll
   Jul-26-2001   23:38  5.0.0.737    106KB  Mqutil.dll
   Jul-26-2001   23:38  5.0.0.720     64KB  Msmq.cpl
   Jul-26-2001   23:38  5.0.0.720    156KB  Msmqocm.dll
				

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Windows 2000 Service Pack 3.

MORE INFORMATION

A secondary cleanup mechanism closes queues if they are not used for a predefined time. The mechanism is enabled by two registry values and is disabled by default. The mechanism only handles queues that are opened by dependent clients.

A counter on each handle counts calls that are processed by the Microsoft Message Queuing Queue Manager at the present time. When the counter decrements to 0, a timer that is configured in the registry is issued. If the counter is still 0 after the timer expires, the Queue Manager closes the handle.

The following are some limitations of the program:
  • The application must have a pending MQReceive call at all times. The timeout of this call controls how fast the Queue Manager closes unused handles. Applications should use short timeouts.
  • If the Queue Manager closes the queue and the application later tries to use the handle, an MQ_ERROR_STALE_HANDLE error (0xc00e0056) is returned. The application must call MQCloseQueue on this handle so that the Queue Manager can release the RPC context handle. Failure to do so leaks the RPC context handle in the Queue Manager.
The following keys are added to the registry for this fix:
  • HKLM\software\Microsoft\MSMQ\Parameters\DepClientContextCleanup This is a DWORD registry entry. If this registry value exists and is non-zero, Queue Manager cleans up potentially orphaned handles of dependent clients that have not called Receive on the queue within the time that is specified by the DepClientCleanupInterval value.

  • HKLM\software\Microsoft\MSMQ\Parameters\DepClientCleanupInterval This is a DWORD registry entry. The value of this key is in seconds. If this value is not present, the default cleanup interval is 120 seconds.

Modification Type:MinorLast Reviewed:9/23/2005
Keywords:kbHotfixServer kbQFE kbbug kbfix kbWin2000sp3fix KB304395