Skip to content

Commit 52483a6

Browse files
authored
Merge pull request #4664 from atlanhq/shotfixalconi
Shotfixalconi
2 parents 3e90ea2 + 5ad9a53 commit 52483a6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

common/src/main/java/org/apache/atlas/service/redis/AbstractRedisService.java

+9-10
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ public abstract class AbstractRedisService implements RedisService {
2727
private static final String ATLAS_REDIS_MASTER_NAME = "atlas.redis.master_name";
2828
private static final String ATLAS_REDIS_LOCK_WAIT_TIME_MS = "atlas.redis.lock.wait_time.ms";
2929
private static final String ATLAS_REDIS_LOCK_WATCHDOG_TIMEOUT_MS = "atlas.redis.lock.watchdog_timeout.ms";
30-
private static final String ATLAS_REDIS_LOCK_LEASE_TIME_MS = "atlas.redis.lock.lease_time.ms";
30+
private static final String ATLAS_REDIS_LEASE_TIME_MS = "atlas.redis.lease_time.ms";
3131
private static final int DEFAULT_REDIS_WAIT_TIME_MS = 15_000;
3232
private static final int DEFAULT_REDIS_LOCK_WATCHDOG_TIMEOUT_MS = 600_000;
33-
// Added default lease time of 30 seconds
34-
private static final int DEFAULT_REDIS_LOCK_LEASE_TIME_MS = 30_000;
33+
private static final int DEFAULT_REDIS_LEASE_TIME_MS = 60_000;
3534
private static final String ATLAS_METASTORE_SERVICE = "atlas-metastore-service";
3635

3736
RedissonClient redisClient;
@@ -48,7 +47,7 @@ public boolean acquireDistributedLock(String key) throws Exception {
4847
boolean isLockAcquired;
4948
try {
5049
RLock lock = redisClient.getFairLock(key);
51-
isLockAcquired = lock.tryLock(waitTimeInMS, leaseTimeInMS, TimeUnit.MILLISECONDS);
50+
isLockAcquired = lock.tryLock(waitTimeInMS, leaseTimeInMS, TimeUnit.MILLISECONDS);
5251
if (isLockAcquired) {
5352
keyLockMap.put(key, lock);
5453
} else {
@@ -61,20 +60,20 @@ public boolean acquireDistributedLock(String key) throws Exception {
6160
return isLockAcquired;
6261
}
6362

63+
6464
@Override
6565
public void releaseDistributedLock(String key) {
66-
if (!keyLockMap.containsKey(key)) {
67-
return;
68-
}
66+
if (!keyLockMap.containsKey(key)) {
67+
return;
68+
}
6969
try {
7070
RLock lock = keyLockMap.get(key);
7171
if (lock.isHeldByCurrentThread()) {
7272
lock.unlock();
7373
}
74-
keyLockMap.remove(key);
74+
7575
} catch (Exception e) {
7676
getLogger().error("Failed to release distributed lock for {}", key, e);
77-
keyLockMap.remove(key);
7877
}
7978
}
8079

@@ -112,7 +111,7 @@ private Config initAtlasConfig() throws AtlasException {
112111
keyLockMap = new ConcurrentHashMap<>();
113112
atlasConfig = ApplicationProperties.get();
114113
waitTimeInMS = atlasConfig.getLong(ATLAS_REDIS_LOCK_WAIT_TIME_MS, DEFAULT_REDIS_WAIT_TIME_MS);
115-
leaseTimeInMS = atlasConfig.getLong(ATLAS_REDIS_LOCK_LEASE_TIME_MS, DEFAULT_REDIS_LOCK_LEASE_TIME_MS);
114+
leaseTimeInMS = atlasConfig.getLong(ATLAS_REDIS_LEASE_TIME_MS, DEFAULT_REDIS_LEASE_TIME_MS);
116115
watchdogTimeoutInMS = atlasConfig.getLong(ATLAS_REDIS_LOCK_WATCHDOG_TIMEOUT_MS, DEFAULT_REDIS_LOCK_WATCHDOG_TIMEOUT_MS);
117116
Config redisConfig = new Config();
118117
redisConfig.setLockWatchdogTimeout(watchdogTimeoutInMS);

webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java

-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,6 @@ public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef, @QueryPar
513513
throw new AtlasBaseException("Error while updating a type definition");
514514
} finally {
515515
RequestContext.clear();
516-
redisService.releaseDistributedLock(ATLAS_TYPEDEF_LOCK);
517516
AtlasPerfTracer.log(perf);
518517
}
519518
}

0 commit comments

Comments
 (0)