Skip to content
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

HBASE-25549 Provide a switch that allows avoiding reopening all regions when modifying a table to prevent RIT storms #5549

Merged
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 @@ -1535,7 +1535,21 @@ default void modifyTable(TableName tableName, TableDescriptor td) throws IOExcep
throw new IllegalArgumentException("the specified table name '" + tableName
+ "' doesn't match with the HTD one: " + td.getTableName());
}
modifyTable(td);
modifyTable(td, true);
}

/**
* Modify an existing table, more IRB friendly version.
* @param td modified description of the table
* @param reopenRegions By default, 'modifyTable' reopens all regions, potentially causing a
* RIT(Region In Transition) storm in large tables. If set to 'false',
* regions will remain unaware of the modification until they are
* individually reopened. Please note that this may temporarily result in
* configuration inconsistencies among regions.
* @throws IOException if a remote or network exception occurs
*/
default void modifyTable(TableDescriptor td, boolean reopenRegions) throws IOException {
get(modifyTableAsync(td, reopenRegions), getSyncWaitTimeout(), TimeUnit.MILLISECONDS);
}

/**
Expand All @@ -1559,7 +1573,7 @@ default void modifyTable(TableDescriptor td) throws IOException {
* @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the
* operation to complete
* @deprecated since 2.0 version and will be removed in 3.0 version. use
* {@link #modifyTableAsync(TableDescriptor)}
* {@link #modifyTableAsync(TableDescriptor, boolean)}
*/
@Deprecated
default Future<Void> modifyTableAsync(TableName tableName, TableDescriptor td)
Expand All @@ -1582,7 +1596,27 @@ default Future<Void> modifyTableAsync(TableName tableName, TableDescriptor td)
* @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the
* operation to complete
*/
Future<Void> modifyTableAsync(TableDescriptor td) throws IOException;
default Future<Void> modifyTableAsync(TableDescriptor td) throws IOException {
return modifyTableAsync(td, true);
}

/**
* Modify an existing table, more IRB (ruby) friendly version. Asynchronous operation. This means
* that it may be a while before your schema change is updated across all of the table. You can
* use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
* ExecutionException if there was an error while executing the operation or TimeoutException in
* case the wait timeout was not long enough to allow the operation to complete.
* @param td description of the table
* @param reopenRegions By default, 'modifyTableAsync' reopens all regions, potentially causing a
* RIT(Region In Transition) storm in large tables. If set to 'false',
* regions will remain unaware of the modification until they are
* individually reopened. Please note that this may temporarily result in
* configuration inconsistencies among regions.
* @throws IOException if a remote or network exception occurs
* @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the
* operation to complete
*/
Future<Void> modifyTableAsync(TableDescriptor td, boolean reopenRegions) throws IOException;
bbeaudreault marked this conversation as resolved.
Show resolved Hide resolved

/**
* Change the store file tracker of the given table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,20 @@ CompletableFuture<Void> createTable(TableDescriptor desc, byte[] startKey, byte[
* Modify an existing table, more IRB friendly version.
* @param desc modified description of the table
*/
CompletableFuture<Void> modifyTable(TableDescriptor desc);
default CompletableFuture<Void> modifyTable(TableDescriptor desc) {
return modifyTable(desc, true);
}

/**
* Modify an existing table, more IRB friendly version.
* @param desc description of the table
* @param reopenRegions By default, 'modifyTable' reopens all regions, potentially causing a RIT
* (Region In Transition) storm in large tables. If set to 'false', regions
* will remain unaware of the modification until they are individually
* reopened. Please note that this may temporarily result in configuration
* inconsistencies among regions.
*/
CompletableFuture<Void> modifyTable(TableDescriptor desc, boolean reopenRegions);

/**
* Change the store file tracker of the given table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ public CompletableFuture<Void> createTable(TableDescriptor desc, byte[][] splitK

@Override
public CompletableFuture<Void> modifyTable(TableDescriptor desc) {
return wrap(rawAdmin.modifyTable(desc));
return modifyTable(desc, true);
}

@Override
public CompletableFuture<Void> modifyTable(TableDescriptor desc, boolean reopenRegions) {
return wrap(rawAdmin.modifyTable(desc, reopenRegions));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ public TableDescriptor getDescriptor(TableName tableName)
}

@Override
public Future<Void> modifyTableAsync(TableDescriptor td) throws IOException {
public Future<Void> modifyTableAsync(TableDescriptor td, boolean reopenRegions)
throws IOException {
ModifyTableResponse response = executeCallable(
new MasterCallable<ModifyTableResponse>(getConnection(), getRpcControllerFactory()) {
long nonceGroup = ng.getNonceGroup();
Expand All @@ -401,8 +402,8 @@ public Future<Void> modifyTableAsync(TableDescriptor td) throws IOException {
@Override
protected ModifyTableResponse rpcCall() throws Exception {
setPriority(td.getTableName());
ModifyTableRequest request =
RequestConverter.buildModifyTableRequest(td.getTableName(), td, nonceGroup, nonce);
ModifyTableRequest request = RequestConverter.buildModifyTableRequest(td.getTableName(),
td, nonceGroup, nonce, reopenRegions);
return master.modifyTable(getRpcController(), request);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,14 @@ private CompletableFuture<Void> createTable(TableName tableName, CreateTableRequ

@Override
public CompletableFuture<Void> modifyTable(TableDescriptor desc) {
return modifyTable(desc, true);
}

public CompletableFuture<Void> modifyTable(TableDescriptor desc, boolean reopenRegions) {
// TODO fill the request with reopenRegions
return this.<ModifyTableRequest, ModifyTableResponse> procedureCall(desc.getTableName(),
RequestConverter.buildModifyTableRequest(desc.getTableName(), desc, ng.getNonceGroup(),
ng.newNonce()),
ng.newNonce(), reopenRegions),
(s, c, req, done) -> s.modifyTable(c, req, done), (resp) -> resp.getProcId(),
new ModifyTableProcedureBiConsumer(this, desc.getTableName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1306,12 +1306,14 @@ public static CreateTableRequest buildCreateTableRequest(final TableDescriptor t
* @return a ModifyTableRequest
*/
public static ModifyTableRequest buildModifyTableRequest(final TableName tableName,
final TableDescriptor tableDesc, final long nonceGroup, final long nonce) {
final TableDescriptor tableDesc, final long nonceGroup, final long nonce,
boolean reopenRegions) {
ModifyTableRequest.Builder builder = ModifyTableRequest.newBuilder();
builder.setTableName(ProtobufUtil.toProtoTableName(tableName));
builder.setTableSchema(ProtobufUtil.toTableSchema(tableDesc));
builder.setNonceGroup(nonceGroup);
builder.setNonce(nonce);
builder.setReopenRegions(reopenRegions);
return builder.build();
}

Expand Down
1 change: 1 addition & 0 deletions hbase-protocol-shaded/src/main/protobuf/Master.proto
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ message ModifyTableRequest {
required TableSchema table_schema = 2;
optional uint64 nonce_group = 3 [default = 0];
optional uint64 nonce = 4 [default = 0];
optional bool reopen_regions = 5 [default = true];
}

message ModifyTableResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ message ModifyTableStateData {
required TableSchema modified_table_schema = 3;
required bool delete_column_family_in_modify = 4;
optional bool should_check_descriptor = 5;
optional bool reopen_regions = 6;
}

enum TruncateTableState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ private void finishActiveMasterInitialization() throws IOException, InterruptedE
procedureExecutor.submitProcedure(new ModifyTableProcedure(
procedureExecutor.getEnvironment(), TableDescriptorBuilder.newBuilder(metaDesc)
.setRegionReplication(replicasNumInConf).build(),
null, metaDesc, false));
null, metaDesc, false, true));
}
}
}
Expand Down Expand Up @@ -2720,6 +2720,13 @@ protected String getDescription() {
private long modifyTable(final TableName tableName,
final TableDescriptorGetter newDescriptorGetter, final long nonceGroup, final long nonce,
final boolean shouldCheckDescriptor) throws IOException {
return modifyTable(tableName, newDescriptorGetter, nonceGroup, nonce, shouldCheckDescriptor,
true);
}

private long modifyTable(final TableName tableName,
final TableDescriptorGetter newDescriptorGetter, final long nonceGroup, final long nonce,
final boolean shouldCheckDescriptor, final boolean reopenRegions) throws IOException {
return MasterProcedureUtil
.submitProcedure(new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {
@Override
Expand All @@ -2738,7 +2745,7 @@ protected void run() throws IOException {
// checks. This will block only the beginning of the procedure. See HBASE-19953.
ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();
submitProcedure(new ModifyTableProcedure(procedureExecutor.getEnvironment(),
newDescriptor, latch, oldDescriptor, shouldCheckDescriptor));
newDescriptor, latch, oldDescriptor, shouldCheckDescriptor, reopenRegions));
latch.await();

getMaster().getMasterCoprocessorHost().postModifyTable(tableName, oldDescriptor,
Expand All @@ -2755,14 +2762,14 @@ protected String getDescription() {

@Override
public long modifyTable(final TableName tableName, final TableDescriptor newDescriptor,
final long nonceGroup, final long nonce) throws IOException {
final long nonceGroup, final long nonce, final boolean reopenRegions) throws IOException {
checkInitialized();
return modifyTable(tableName, new TableDescriptorGetter() {
@Override
public TableDescriptor get() throws IOException {
return newDescriptor;
}
}, nonceGroup, nonce, false);
}, nonceGroup, nonce, false, reopenRegions);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,8 @@ public ModifyTableResponse modifyTable(RpcController controller, ModifyTableRequ
throws ServiceException {
try {
long procId = master.modifyTable(ProtobufUtil.toTableName(req.getTableName()),
ProtobufUtil.toTableDescriptor(req.getTableSchema()), req.getNonceGroup(), req.getNonce());
ProtobufUtil.toTableDescriptor(req.getTableSchema()), req.getNonceGroup(), req.getNonce(),
req.getReopenRegions());
return ModifyTableResponse.newBuilder().setProcId(procId).build();
} catch (IOException ioe) {
throw new ServiceException(ioe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,19 @@ public long truncateTable(final TableName tableName, final boolean preserveSplit
* @param tableName The table name
* @param descriptor The updated table descriptor
*/
default long modifyTable(final TableName tableName, final TableDescriptor descriptor,
final long nonceGroup, final long nonce) throws IOException {
return modifyTable(tableName, descriptor, nonceGroup, nonce, true);
}

/**
* Modify the descriptor of an existing table
* @param tableName The table name
* @param descriptor The updated table descriptor
* @param reopenRegions Whether to reopen regions after modifying the table descriptor
*/
long modifyTable(final TableName tableName, final TableDescriptor descriptor,
final long nonceGroup, final long nonce) throws IOException;
final long nonceGroup, final long nonce, final boolean reopenRegions) throws IOException;

/**
* Modify the store file tracker of an existing table
Expand Down
Loading