Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ message CloneSnapshotStateData {
required TableSchema table_schema = 3;
repeated RegionInfo region_info = 4;
repeated RestoreParentToChildRegionsPair parent_to_child_regions_pair_list = 5;
optional bool restore_acl = 6;
}

enum RestoreSnapshotState {
Expand All @@ -225,6 +226,7 @@ message RestoreSnapshotStateData {
repeated RegionInfo region_info_for_remove = 5;
repeated RegionInfo region_info_for_add = 6;
repeated RestoreParentToChildRegionsPair parent_to_child_regions_pair_list = 7;
optional bool restore_acl = 8;
}

enum DispatchMergingRegionsState {
Expand Down Expand Up @@ -654,4 +656,4 @@ enum ModifyTableDescriptorState {
message ModifyTableDescriptorStateData {
required TableSchema unmodified_table_schema = 1;
optional TableSchema modified_table_schema = 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.hadoop.hbase.master.procedure;

import com.google.errorprone.annotations.RestrictedApi;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -271,6 +272,8 @@ protected void serializeStateData(ProcedureStateSerializer serializer)
.setUserInfo(MasterProcedureUtil.toProtoUserInfo(getUser()))
.setSnapshot(this.snapshot)
.setTableSchema(ProtobufUtil.toTableSchema(tableDescriptor));

cloneSnapshotMsg.setRestoreAcl(restoreAcl);
if (newRegions != null) {
for (RegionInfo hri: newRegions) {
cloneSnapshotMsg.addRegionInfo(ProtobufUtil.toRegionInfo(hri));
Expand Down Expand Up @@ -303,6 +306,9 @@ protected void deserializeStateData(ProcedureStateSerializer serializer)
setUser(MasterProcedureUtil.toUserInfo(cloneSnapshotMsg.getUserInfo()));
snapshot = cloneSnapshotMsg.getSnapshot();
tableDescriptor = ProtobufUtil.toTableDescriptor(cloneSnapshotMsg.getTableSchema());
if (cloneSnapshotMsg.hasRestoreAcl()) {
restoreAcl = cloneSnapshotMsg.getRestoreAcl();
}
if (cloneSnapshotMsg.getRegionInfoCount() == 0) {
newRegions = null;
} else {
Expand Down Expand Up @@ -521,4 +527,13 @@ private void addRegionsToMeta(final MasterProcedureEnv env) throws IOException {
metaChanges.updateMetaParentRegions(env.getMasterServices().getConnection(), newRegions);
}

/**
* Exposed for Testing: HBASE-26462
*/
@RestrictedApi(explanation = "Should only be called in tests", link = "",
allowedOnPath = ".*/src/test/.*")
public boolean getRestoreAcl() {
return restoreAcl;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.hadoop.hbase.master.procedure;

import com.google.errorprone.annotations.RestrictedApi;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -272,6 +273,7 @@ protected void serializeStateData(ProcedureStateSerializer serializer)
restoreSnapshotMsg.addParentToChildRegionsPairList (parentToChildrenPair);
}
}
restoreSnapshotMsg.setRestoreAcl(restoreAcl);
serializer.serialize(restoreSnapshotMsg.build());
}

Expand Down Expand Up @@ -321,6 +323,9 @@ protected void deserializeStateData(ProcedureStateSerializer serializer)
parentToChildrenPair.getChild2RegionName()));
}
}
if (restoreSnapshotMsg.hasRestoreAcl()) {
restoreAcl = restoreSnapshotMsg.getRestoreAcl();
}
}

/**
Expand Down Expand Up @@ -545,4 +550,13 @@ private void restoreSnapshotAcl(final MasterProcedureEnv env) throws IOException
env.getMasterServices().getConfiguration());
}
}

/**
* Exposed for Testing: HBASE-26462
*/
@RestrictedApi(explanation = "Should only be called in tests", link = "",
allowedOnPath = ".*/src/test/.*")
public boolean getRestoreAcl() {
return restoreAcl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase.master.procedure;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.List;
Expand Down Expand Up @@ -162,6 +163,31 @@ public void testRecoveryAndDoubleExecution() throws Exception {
clonedTableName);
}

@Test
public void testRecoverWithRestoreAclFlag() throws Exception {
// This test is to solve the problems mentioned in HBASE-26462,
// this needs to simulate the case of CloneSnapshotProcedure failure and recovery,
// and verify whether 'restoreAcl' flag can obtain the correct value.

final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
final TableName clonedTableName = TableName.valueOf("testRecoverWithRestoreAclFlag");
final TableDescriptor htd = createTableDescriptor(clonedTableName, CF);

SnapshotProtos.SnapshotDescription snapshotDesc = getSnapshot();
ProcedureTestingUtility.setKillIfHasParent(procExec, false);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

// Start the Clone snapshot procedure (with restoreAcl 'true') && kill the executor
long procId = procExec.submitProcedure(
new CloneSnapshotProcedure(procExec.getEnvironment(), htd, snapshotDesc, true));

MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId);

CloneSnapshotProcedure result = (CloneSnapshotProcedure)procExec.getResult(procId);
// check whether the 'restoreAcl' flag is true after deserialization from Pb.
assertEquals(true, result.getRestoreAcl());
}

@Test
public void testRollbackAndDoubleExecution() throws Exception {
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,25 @@ public void testRecoveryAndDoubleExecution() throws Exception {
validateSnapshotRestore();
}

@Test
public void testRecoverWithRestoreAclFlag() throws Exception {
// This test is to solve the problems mentioned in HBASE-26462,
// this needs to simulate the case of RestoreSnapshotProcedure failure and recovery,
// and verify whether 'restoreAcl' flag can obtain the correct value.

final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

// Start the Restore snapshot procedure (with restoreAcl 'true') && kill the executor
long procId = procExec.submitProcedure(
new RestoreSnapshotProcedure(procExec.getEnvironment(), snapshotHTD, snapshot, true));
MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId);

RestoreSnapshotProcedure result = (RestoreSnapshotProcedure)procExec.getResult(procId);
// check whether the restoreAcl flag is true after deserialization from Pb.
assertEquals(true, result.getRestoreAcl());
}

private void validateSnapshotRestore() throws IOException {
try {
UTIL.getAdmin().enableTable(snapshotTableName);
Expand Down