|
The datanode has a new directory per volume called "detachDir". This directory is used to do temporary copy-on-write for data blocks that are part of a snapshot.
When a client writes a block that is linked to a snapshot, it does the following: 1. Create a copy of the original file into a file in the detachDir. Point 2 works perfectly on Linux platform. The following are some caveats on Windows platform. On Windows platform, the rename fails because the target file already exists. Thus, the code issues a delete followed by a rename. This means that there is a window of opportunity (on Windows) when the block does not exist in the right place. If a read request for the block occurs precisely in that window, then the client will get an exception and will try to read that block from an alternate location. (When a datanode restarts, it recovers blocks that are exist in detachDir but do not exist in the original data directory.) I am proposing that this is an acceptable solution.
This patch does a copy-on-write for blocks that need modification but were linked to an existing snapshot. As part of this patch, the two maps in the datanode (volumeMap and blockMap) are combined into one single map.
Merged patch with latest trunk.
1. Moved most of detachBlock to DatanodeBlockInfo.java.
2. It is not a public interface anymore. Removed it from FSDatasetInterface.java 3. numLinks is needed to drive the unit tests. It is also needed to make the method handle the case when there are possibly multiple snapshots in the future. 4. I did not make createDetachFile() static, especially because it refers to the detachDir variable. 5. Moved replaceFile to FileUtil. It is intended to handle OS specific cases when the rename will fail if somebody else has a handle to the target file. The current setting of the retry time-limit is adhoc. During this period, it is likely that another thread that was reading that block file will be done reading it. Triggering Hudson tests.
-1 overall. Here are the results of testing the latest attachment
http://issues.apache.org/jira/secure/attachment/12376078/copyOnWrite2.patch against trunk revision 619744. @author +1. The patch does not contain any @author tags. tests included +1. The patch appears to include 7 new or modified tests. javadoc +1. The javadoc tool did not generate any warning messages. javac +1. The applied patch does not generate any new javac compiler warnings. release audit +1. The applied patch does not generate any new release audit warnings. findbugs -1. The patch appears to introduce 3 new Findbugs warnings. core tests -1. The patch failed core unit tests. contrib tests +1. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/1822/testReport/ This message is automatically generated. The "stat" command is not available on solaris. Use "ls -l" on solaris.
Fixed findbugs warnings. +1 overall. Here are the results of testing the latest attachment
http://issues.apache.org/jira/secure/attachment/12376169/copyOnWrite3.patch against trunk revision 619744. @author +1. The patch does not contain any @author tags. tests included +1. The patch appears to include 7 new or modified tests. javadoc +1. The javadoc tool did not generate any warning messages. javac +1. The applied patch does not generate any new javac compiler warnings. release audit +1. The applied patch does not generate any new release audit warnings. findbugs +1. The patch does not introduce any new Findbugs warnings. core tests +1. The patch passed core unit tests. contrib tests +1. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/1831/testReport/ This message is automatically generated.
I just committed this. Thanks Konstantin.
Integrated in Hadoop-trunk #412 (See http://hudson.zones.apache.org/hudson/job/Hadoop-trunk/412/
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://issues.apache.org/jira/browse/HADOOP-2012?focusedCommentId=12548478#action_12548478