Skip to content

HBASE-29291: Add a command to refresh/sync hbase:meta table #7058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: HBASE-29081
Choose a base branch
from
Open
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 @@ -2651,4 +2651,9 @@ List<LogEntry> getLogEntries(Set<ServerName> serverNames, String logType, Server
* Get the list of cached files
*/
List<String> getCachedFilesList(ServerName serverName) throws IOException;

/**
* Perform hbase:meta table refresh
*/
Long refreshMeta() throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1136,4 +1136,9 @@ public void flushMasterStore() throws IOException {
public List<String> getCachedFilesList(ServerName serverName) throws IOException {
return get(admin.getCachedFilesList(serverName));
}

@Override
public Long refreshMeta() throws IOException {
return get(admin.refreshMeta());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1862,4 +1862,9 @@ CompletableFuture<List<LogEntry>> getLogEntries(Set<ServerName> serverNames, Str
* Get the list of cached files
*/
CompletableFuture<List<String>> getCachedFilesList(ServerName serverName);

/**
* Perform hbase:meta table refresh
*/
CompletableFuture<Long> refreshMeta();
}
Original file line number Diff line number Diff line change
Expand Up @@ -1005,4 +1005,9 @@ public CompletableFuture<Void> flushMasterStore() {
public CompletableFuture<List<String>> getCachedFilesList(ServerName serverName) {
return wrap(rawAdmin.getCachedFilesList(serverName));
}

@Override
public CompletableFuture<Long> refreshMeta() {
return wrap(rawAdmin.refreshMeta());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.OfflineRegionResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RecommissionRegionServerRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RecommissionRegionServerResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RefreshMetaRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RefreshMetaResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCatalogScanRequest;
Expand Down Expand Up @@ -4557,4 +4559,16 @@ List<String>> adminCall(controller, stub, request.build(),
resp -> resp.getCachedFilesList()))
.serverName(serverName).call();
}

@Override
public CompletableFuture<Long> refreshMeta() {
RefreshMetaRequest.Builder request = RefreshMetaRequest.newBuilder();
request.setNonceGroup(ng.getNonceGroup()).setNonce(ng.newNonce());
return this.<Long> newMasterCaller()
.action((controller, stub) -> this.<RefreshMetaRequest, RefreshMetaResponse, Long> call(
controller, stub, request.build(), MasterService.Interface::refreshMeta,
RefreshMetaResponse::getProcId))
.call();
}

}
11 changes: 11 additions & 0 deletions hbase-protocol-shaded/src/main/protobuf/server/master/Master.proto
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,14 @@ message ModifyColumnStoreFileTrackerResponse {
message FlushMasterStoreRequest {}
message FlushMasterStoreResponse {}

message RefreshMetaRequest {
optional uint64 nonce_group = 1 [default = 0];
optional uint64 nonce = 2 [default = 0];
}
message RefreshMetaResponse {
optional uint64 proc_id = 1;
}

service MasterService {
/** Used by the client to get the number of regions that have received the updated schema */
rpc GetSchemaAlterStatus(GetSchemaAlterStatusRequest)
Expand Down Expand Up @@ -1270,6 +1278,9 @@ service MasterService {

rpc FlushTable(FlushTableRequest)
returns(FlushTableResponse);

rpc RefreshMeta(RefreshMetaRequest)
returns(RefreshMetaResponse);
}

// HBCK Service definitions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,3 +821,13 @@ enum CloseTableRegionsProcedureState {
message CloseTableRegionsProcedureStateData {
required TableName table_name = 1;
}

enum RefreshMetaState {
REFRESH_META_INIT = 1;
REFRESH_META_SCAN_STORAGE = 2;
REFRESH_META_UPDATE = 3;
REFRESH_META_COMPLETE = 4;
}

message RefreshMetaStateData {
}
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ private static void deleteFromMetaTable(final Connection connection, final Delet
* @param connection connection we're using
* @param deletes Deletes to add to hbase:meta This list should support #remove.
*/
private static void deleteFromMetaTable(final Connection connection, final List<Delete> deletes)
public static void deleteFromMetaTable(final Connection connection, final List<Delete> deletes)
throws IOException {
try (Table t = getMetaHTable(connection)) {
debugLogMutations(deletes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
import org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch;
import org.apache.hadoop.hbase.master.procedure.ProcedureSyncWait;
import org.apache.hadoop.hbase.master.procedure.RSProcedureDispatcher;
import org.apache.hadoop.hbase.master.procedure.RefreshMetaProcedure;
import org.apache.hadoop.hbase.master.procedure.ReopenTableRegionsProcedure;
import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
import org.apache.hadoop.hbase.master.procedure.TruncateRegionProcedure;
Expand Down Expand Up @@ -246,6 +247,7 @@
import org.apache.hadoop.hbase.security.SecurityConstants;
import org.apache.hadoop.hbase.security.Superusers;
import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos;
import org.apache.hadoop.hbase.trace.TraceUtil;
import org.apache.hadoop.hbase.util.Addressing;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -4543,4 +4545,21 @@ protected String getDescription() {
}
});
}

public Long refreshMeta(long nonceGroup, long nonce) throws IOException {
return MasterProcedureUtil
.submitProcedure(new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {
@Override
protected void run() throws IOException {
LOG.info("Submitting RefreshMetaProcedure");
submitProcedure(
new RefreshMetaProcedure(procedureExecutor.getEnvironment()));
}

@Override
protected String getDescription() {
return "RefreshMetaProcedure";
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil.NonceProcedureRunnable;
import org.apache.hadoop.hbase.master.procedure.RefreshMetaProcedure;
import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
import org.apache.hadoop.hbase.master.replication.AbstractPeerNoLockProcedure;
import org.apache.hadoop.hbase.mob.MobUtils;
Expand Down Expand Up @@ -113,6 +114,7 @@
import org.apache.hadoop.hbase.security.access.ShadedAccessControlUtil;
import org.apache.hadoop.hbase.security.access.UserPermission;
import org.apache.hadoop.hbase.security.visibility.VisibilityController;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos;
import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils;
import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -3661,4 +3663,15 @@ public FlushTableResponse flushTable(RpcController controller, FlushTableRequest
throw new ServiceException(ioe);
}
}

@Override public MasterProtos.RefreshMetaResponse refreshMeta(RpcController controller,
MasterProtos.RefreshMetaRequest request) throws ServiceException {
try {
Long procId =
server.refreshMeta(request.getNonceGroup(), request.getNonce());
return MasterProtos.RefreshMetaResponse.newBuilder().setProcId(procId).build();
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
}
}
Loading