HBASE-9607 Data loss after snapshot restore into cloned table

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1525352 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
mbertozzi 2013-09-22 12:22:08 +00:00
parent bbbceb5cbf
commit 9a8821d77d
2 changed files with 23 additions and 8 deletions

View File

@ -389,13 +389,6 @@ public class RestoreSnapshotHelper {
}
}
// Restore Missing files
for (String hfileName: hfilesToAdd) {
LOG.trace("Adding HFileLink " + hfileName +
" to region=" + regionInfo.getEncodedName() + " table=" + tableName);
restoreStoreFile(familyDir, regionInfo, hfileName);
}
// Remove hfiles not present in the snapshot
for (String hfileName: familyFiles) {
Path hfile = new Path(familyDir, hfileName);
@ -403,6 +396,13 @@ public class RestoreSnapshotHelper {
" from region=" + regionInfo.getEncodedName() + " table=" + tableName);
HFileArchiver.archiveStoreFile(conf, fs, regionInfo, tableDir, family, hfile);
}
// Restore Missing files
for (String hfileName: hfilesToAdd) {
LOG.trace("Adding HFileLink " + hfileName +
" to region=" + regionInfo.getEncodedName() + " table=" + tableName);
restoreStoreFile(familyDir, regionInfo, hfileName);
}
} else {
// Family doesn't exists in the snapshot
LOG.trace("Removing family=" + Bytes.toString(family) +

View File

@ -222,7 +222,7 @@ public class TestRestoreSnapshotFromClient {
}
@Test
public void testRestoreSnapshotOfCloned() throws IOException, InterruptedException {
public void testCloneSnapshotOfCloned() throws IOException, InterruptedException {
TableName clonedTableName =
TableName.valueOf("clonedtb-" + System.currentTimeMillis());
admin.cloneSnapshot(snapshotName0, clonedTableName);
@ -237,6 +237,21 @@ public class TestRestoreSnapshotFromClient {
TEST_UTIL.deleteTable(clonedTableName);
}
@Test
public void testCloneAndRestoreSnapshot() throws IOException, InterruptedException {
TEST_UTIL.deleteTable(tableName);
waitCleanerRun();
admin.cloneSnapshot(snapshotName0, tableName);
SnapshotTestingUtils.verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
waitCleanerRun();
admin.disableTable(tableName);
admin.restoreSnapshot(snapshotName0);
admin.enableTable(tableName);
SnapshotTestingUtils.verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
}
// ==========================================================================
// Helpers
// ==========================================================================