diff --git a/hdfs/CHANGES.txt b/hdfs/CHANGES.txt index 158c9f734a..5148ea243d 100644 --- a/hdfs/CHANGES.txt +++ b/hdfs/CHANGES.txt @@ -961,6 +961,9 @@ Trunk (unreleased changes) HDFS-2186. DN volume failures on startup are not counted. (eli) + HDFS-2240. Fix a deadlock in LeaseRenewer by enforcing lock acquisition + ordering. (szetszwo) + BREAKDOWN OF HDFS-1073 SUBTASKS HDFS-1521. Persist transaction ID on disk between NN restarts. diff --git a/hdfs/src/java/org/apache/hadoop/hdfs/LeaseRenewer.java b/hdfs/src/java/org/apache/hadoop/hdfs/LeaseRenewer.java index e86ac1e68c..ba26ad2c24 100644 --- a/hdfs/src/java/org/apache/hadoop/hdfs/LeaseRenewer.java +++ b/hdfs/src/java/org/apache/hadoop/hdfs/LeaseRenewer.java @@ -75,7 +75,9 @@ class LeaseRenewer { /** Get a {@link LeaseRenewer} instance */ static LeaseRenewer getInstance(final String authority, final UserGroupInformation ugi, final DFSClient dfsc) throws IOException { - return Factory.INSTANCE.get(authority, ugi, dfsc); + final LeaseRenewer r = Factory.INSTANCE.get(authority, ugi); + r.addClient(dfsc); + return r; } /** @@ -132,14 +134,13 @@ public String toString() { /** Get a renewer. */ private synchronized LeaseRenewer get(final String authority, - final UserGroupInformation ugi, final DFSClient dfsc) { + final UserGroupInformation ugi) { final Key k = new Key(authority, ugi); LeaseRenewer r = renewers.get(k); if (r == null) { r = new LeaseRenewer(k); renewers.put(k, r); } - r.addClient(dfsc); return r; } @@ -196,7 +197,7 @@ private synchronized void remove(final LeaseRenewer r) { private LeaseRenewer(Factory.Key factorykey) { this.factorykey = factorykey; - setGraceSleepPeriod(LEASE_RENEWER_GRACE_DEFAULT); + unsyncSetGraceSleepPeriod(LEASE_RENEWER_GRACE_DEFAULT); if (LOG.isTraceEnabled()) { instantiationTrace = StringUtils.stringifyException( @@ -251,6 +252,10 @@ private synchronized long getSleepPeriod() { /** Set the grace period and adjust the sleep period accordingly. */ synchronized void setGraceSleepPeriod(final long gracePeriod) { + unsyncSetGraceSleepPeriod(gracePeriod); + } + + private void unsyncSetGraceSleepPeriod(final long gracePeriod) { if (gracePeriod < 100L) { throw new HadoopIllegalArgumentException(gracePeriod + " = gracePeriod < 100ms is too small.");