Hi,
We have a SQL Server 2008 Merge Publication (Merge Pull Replication)
All subscribers are running SQL Server Express 2008.
The replication has been working fine for 2 years with 40 subscribers; suddenly 1 subscriber is being unable to sync.
The error is always the same: “Unexpected failure releasing an application lock. Ensure that the account under which the Merge Agent runs is a member of the publication access list. If there is a lot of activity on the server, run the Merge Agent when there are more server resources available”
Here is the log with -OutputVerboseLevel 1:
2014-01-30 08:44:31.279 Connecting to Subscriber 'ARosario-01\SQLEXPRESS' 2014-01-30 08:44:32.844 Connecting to Distributor 'SRVR-IPOINT' 2014-01-30 08:44:34.024 Initializing 2014-01-30 08:44:34.069 Connecting to Publisher 'SRVR-IPOINT' 2014-01-30 08:44:56.249 Thread id 2184 is attempting to re-establish the connection to Publisher 'SRVR-IPOINT'. 2014-01-30 08:44:56.439 Thread id 2184 successfully re-established connection to Publisher 'SRVR-IPOINT'. 2014-01-30 08:44:56.489 The merge process could not acquire application locks successfully 2014-01-30 08:44:56.604 Category:NULL Source: Merge Replication Provider Number: -2147199472 Message: The merge process could not acquire application locks successfully 2014-01-30 08:44:56.659 Category:SQLSERVER Source: SRVR-IPOINT Number: 21415 Message: Unexpected failure releasing an application lock. Ensure that the account under which the Merge Agent runs is a member of the publication access list. If there is a lot of activity on the server, run the Merge Agent when there are more server resources available.
What I find very strange is that always it’s throwing:
Thread id xxx successfully re-established connection to Publisher 'SRVR-IPOINT'.
Using -OutputVerboseLevel 4 and tracing the process, I found that the entire problem is in sp_MSacquireSlotLock:
{call sp_MSacquireSlotLock (N'ReplicationMergeAgent047a5d7a17b44af98f8bb9c9773eddd7',?, ?, ?) }
The procees acquires the lock fine in line 101:
exec @retcode=sys.sp_getapplock @Resource=@slot_name,@LockMode=N'Exclusive', @LockOwner='Session',@LockTimeout=0,@DbPrincipal=@DbPrincipal
but later on line 115, fails releasing the lock.
exec @retcode=sys.sp_releaseapplock @process_name,@LockOwner=N'Session',@DbPrincipal=@DbPrincipal
First of all, what it’s very strange is that inside the code, the lock is requested for @Resource=@slot_name but it’s released for @process_name.
Nevertheless, it’s working fine for all the rest of subscribers.
The only thing that I’m thinking is that maybe the loose of connection is releasing the lock before the release command execute:
439 Thread id 2184 successfully re-established connection to Publisher 'SRVR-IPOINT'.
Troubleshooting, I created new subscriptions with new databases in the same subscriber but I get the same error. Also, using another “HOST_NAME” to sync.
Please, I will appreciate all your help as we have a subscriber with 3 days of information that we can’t upload to the server.
Best Regards,
Daniel.