mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
REPO-4556 Lock prop cleanup and LDAP with same token (#532)
This commit is contained in:
@@ -28,6 +28,7 @@ package org.alfresco.repo.attributes;
|
|||||||
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
||||||
import org.alfresco.repo.lock.JobLockService;
|
import org.alfresco.repo.lock.JobLockService;
|
||||||
import org.alfresco.repo.lock.LockAcquisitionException;
|
import org.alfresco.repo.lock.LockAcquisitionException;
|
||||||
|
import org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizer;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
@@ -74,11 +75,14 @@ public class PropTablesCleaner
|
|||||||
{
|
{
|
||||||
checkProperties();
|
checkProperties();
|
||||||
|
|
||||||
String lockToken = null;
|
String propCleanUplockToken = null;
|
||||||
|
String ldapSyncLockTocken = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get a lock
|
// Get a lock for cleanup
|
||||||
lockToken = jobLockService.getLock(LOCK_QNAME, LOCK_TTL);
|
propCleanUplockToken = jobLockService.getLock(LOCK_QNAME, LOCK_TTL);
|
||||||
|
// Get a lock for LDAP sync as well, see REPO-4556
|
||||||
|
ldapSyncLockTocken = jobLockService.getLock(ChainingUserRegistrySynchronizer.LOCK_QNAME, LOCK_TTL);
|
||||||
propertyValueDAO.cleanupUnusedValues();
|
propertyValueDAO.cleanupUnusedValues();
|
||||||
}
|
}
|
||||||
catch (LockAcquisitionException e)
|
catch (LockAcquisitionException e)
|
||||||
@@ -90,11 +94,22 @@ public class PropTablesCleaner
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (lockToken != null)
|
if (propCleanUplockToken != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
jobLockService.releaseLock(lockToken, LOCK_QNAME);
|
jobLockService.releaseLock(propCleanUplockToken, LOCK_QNAME);
|
||||||
|
}
|
||||||
|
catch (LockAcquisitionException e)
|
||||||
|
{
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ldapSyncLockTocken != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jobLockService.releaseLock(ldapSyncLockTocken, ChainingUserRegistrySynchronizer.LOCK_QNAME);
|
||||||
}
|
}
|
||||||
catch (LockAcquisitionException e)
|
catch (LockAcquisitionException e)
|
||||||
{
|
{
|
||||||
|
@@ -113,7 +113,7 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
|||||||
private static final Log logger = LogFactory.getLog(ChainingUserRegistrySynchronizer.class);
|
private static final Log logger = LogFactory.getLog(ChainingUserRegistrySynchronizer.class);
|
||||||
|
|
||||||
/** The name of the lock used to ensure that a synchronize does not run on more than one node at the same time. */
|
/** The name of the lock used to ensure that a synchronize does not run on more than one node at the same time. */
|
||||||
private static final QName LOCK_QNAME = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI,
|
public static final QName LOCK_QNAME = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI,
|
||||||
"ChainingUserRegistrySynchronizer");
|
"ChainingUserRegistrySynchronizer");
|
||||||
|
|
||||||
/** The time this lock will persist for in the database (now only 2 minutes but refreshed at regular intervals). */
|
/** The time this lock will persist for in the database (now only 2 minutes but refreshed at regular intervals). */
|
||||||
|
Reference in New Issue
Block a user