|
@@ -1129,8 +1129,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
createParent, replication, blockSize);
|
|
createParent, replication, blockSize);
|
|
} finally {
|
|
} finally {
|
|
writeUnlock();
|
|
writeUnlock();
|
|
|
|
+ // There might be transactions logged while trying to recover the lease.
|
|
|
|
+ // They need to be sync'ed even when an exception was thrown.
|
|
|
|
+ getEditLog().logSync();
|
|
}
|
|
}
|
|
- getEditLog().logSync();
|
|
|
|
if (auditLog.isInfoEnabled() && isExternalInvocation()) {
|
|
if (auditLog.isInfoEnabled() && isExternalInvocation()) {
|
|
final HdfsFileStatus stat = dir.getFileInfo(src, false);
|
|
final HdfsFileStatus stat = dir.getFileInfo(src, false);
|
|
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
@@ -1336,6 +1338,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
recoverLeaseInternal(inode, src, holder, clientMachine, true);
|
|
recoverLeaseInternal(inode, src, holder, clientMachine, true);
|
|
} finally {
|
|
} finally {
|
|
writeUnlock();
|
|
writeUnlock();
|
|
|
|
+ // There might be transactions logged while trying to recover the lease.
|
|
|
|
+ // They need to be sync'ed even when an exception was thrown.
|
|
|
|
+ getEditLog().logSync();
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -1437,8 +1442,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
false, blockManager.maxReplication, (long)0);
|
|
false, blockManager.maxReplication, (long)0);
|
|
} finally {
|
|
} finally {
|
|
writeUnlock();
|
|
writeUnlock();
|
|
|
|
+ // There might be transactions logged while trying to recover the lease.
|
|
|
|
+ // They need to be sync'ed even when an exception was thrown.
|
|
|
|
+ getEditLog().logSync();
|
|
}
|
|
}
|
|
- getEditLog().logSync();
|
|
|
|
if (lb != null) {
|
|
if (lb != null) {
|
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
|
NameNode.stateChangeLog.debug("DIR* NameSystem.appendFile: file "
|
|
NameNode.stateChangeLog.debug("DIR* NameSystem.appendFile: file "
|
|
@@ -2171,7 +2178,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
* RecoveryInProgressException if lease recovery is in progress.<br>
|
|
* RecoveryInProgressException if lease recovery is in progress.<br>
|
|
* IOException in case of an error.
|
|
* IOException in case of an error.
|
|
* @return true if file has been successfully finalized and closed or
|
|
* @return true if file has been successfully finalized and closed or
|
|
- * false if block recovery has been initiated
|
|
|
|
|
|
+ * false if block recovery has been initiated. Since the lease owner
|
|
|
|
+ * has been changed and logged, caller should call logSync().
|
|
*/
|
|
*/
|
|
boolean internalReleaseLease(Lease lease, String src,
|
|
boolean internalReleaseLease(Lease lease, String src,
|
|
String recoveryLeaseHolder) throws AlreadyBeingCreatedException,
|
|
String recoveryLeaseHolder) throws AlreadyBeingCreatedException,
|
|
@@ -2303,6 +2311,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
assert hasWriteLock();
|
|
assert hasWriteLock();
|
|
if(newHolder == null)
|
|
if(newHolder == null)
|
|
return lease;
|
|
return lease;
|
|
|
|
+ // The following transaction is not synced. Make sure it's sync'ed later.
|
|
logReassignLease(lease.getHolder(), src, newHolder);
|
|
logReassignLease(lease.getHolder(), src, newHolder);
|
|
return reassignLeaseInternal(lease, src, newHolder, pendingFile);
|
|
return reassignLeaseInternal(lease, src, newHolder, pendingFile);
|
|
}
|
|
}
|
|
@@ -4225,13 +4234,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
|
|
|
private void logReassignLease(String leaseHolder, String src,
|
|
private void logReassignLease(String leaseHolder, String src,
|
|
String newHolder) throws IOException {
|
|
String newHolder) throws IOException {
|
|
- writeLock();
|
|
|
|
- try {
|
|
|
|
- getEditLog().logReassignLease(leaseHolder, src, newHolder);
|
|
|
|
- } finally {
|
|
|
|
- writeUnlock();
|
|
|
|
- }
|
|
|
|
- getEditLog().logSync();
|
|
|
|
|
|
+ assert hasWriteLock();
|
|
|
|
+ getEditLog().logReassignLease(leaseHolder, src, newHolder);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|