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:
parent
bbbceb5cbf
commit
9a8821d77d
|
@ -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) +
|
||||
|
|
|
@ -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
|
||||
// ==========================================================================
|
||||
|
|
Loading…
Reference in New Issue