Skip to content

Commit 9b17975

Browse files
committed
fix
1 parent d89f915 commit 9b17975

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AbstractAsyncOperationHandler.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public abstract class AbstractAsyncOperationHandler <T extends TBase, A> {
6565
protected T request;
6666
protected IHMSHandler handler;
6767
protected final String id;
68+
private long timeout;
6869

6970
private AbstractAsyncOperationHandler(String id) {
7071
this.id = id;
@@ -75,6 +76,7 @@ private AbstractAsyncOperationHandler(String id) {
7576
this.handler = handler;
7677
this.request = request;
7778
this.async = async;
79+
this.timeout = MetastoreConf.getBoolVar(handler.getConf(), HIVE_IN_TEST) ? 10 : 5000;
7880
OPID_TO_HANDLER.put(id, this);
7981
if (async) {
8082
this.executor = Executors.newFixedThreadPool(1, r -> {
@@ -86,14 +88,15 @@ private AbstractAsyncOperationHandler(String id) {
8688
} else {
8789
this.executor = MoreExecutors.newDirectExecutorService();
8890
}
89-
this.future = executor.submit(() -> {
90-
try {
91-
return execute();
92-
} finally {
93-
destroy();
94-
OPID_CLEANER.schedule(() -> OPID_TO_HANDLER.remove(id), 1, TimeUnit.HOURS);
95-
}
96-
});
91+
this.future =
92+
executor.submit(() -> {
93+
try {
94+
return execute();
95+
} finally {
96+
destroy();
97+
OPID_CLEANER.schedule(() -> OPID_TO_HANDLER.remove(id), 1, TimeUnit.HOURS);
98+
}
99+
});
97100
this.executor.shutdown();
98101
}
99102

@@ -155,8 +158,7 @@ public OperationStatus getOperationStatus() throws TException {
155158
throw new IllegalStateException(logMsgPrefix + " hasn't started yet");
156159
}
157160
try {
158-
long interval = MetastoreConf.getBoolVar(handler.getConf(), HIVE_IN_TEST) ? 10 : 5000;
159-
result = async ? future.get(interval, TimeUnit.MILLISECONDS) : future.get();
161+
result = async ? future.get(timeout, TimeUnit.MILLISECONDS) : future.get();
160162
} catch (TimeoutException e) {
161163
// No Op, return to the caller since long polling timeout has expired
162164
LOG.trace("{} Long polling timed out", logMsgPrefix);
@@ -165,7 +167,7 @@ public OperationStatus getOperationStatus() throws TException {
165167
LOG.trace("{} The background operation was cancelled", logMsgPrefix);
166168
} catch (ExecutionException | InterruptedException e) {
167169
// No op, we will deal with this exception later
168-
LOG.error(logMsgPrefix + " Failed", e);
170+
LOG.error("{} Failed", logMsgPrefix, e);
169171
if (e.getCause() instanceof Exception ex && !aborted.get()) {
170172
throw handleException(ex).throwIfInstance(TException.class).defaultMetaException();
171173
}
@@ -214,7 +216,7 @@ public void setFinished(boolean finished) {
214216

215217
public void cancelOperation() {
216218
if (!future.isDone()) {
217-
LOG.warn("Drop operation: {} is still running, but a close signal is triggered", id);
219+
LOG.warn("Operation: {} is still running, but a close signal is triggered", id);
218220
future.cancel(true);
219221
aborted.set(true);
220222
}
@@ -269,7 +271,6 @@ public void checkInterrupted() throws MetaException {
269271
*/
270272
void destroy() {
271273
request = null;
272-
executor = null;
273274
handler = null;
274275
}
275276

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AsyncDropTableHandler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import static org.apache.hadoop.hive.metastore.HMSHandler.checkTableDataShouldBeDeleted;
4343
import static org.apache.hadoop.hive.metastore.HMSHandler.isDbReplicationTarget;
44+
import static org.apache.hadoop.hive.metastore.HMSHandler.isMustPurge;
4445
import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog;
4546
import static org.apache.hadoop.hive.metastore.utils.StringUtils.normalizeIdentifier;
4647

@@ -111,7 +112,8 @@ public DropTableResult dropTable() throws TException {
111112
}
112113
success = ms.commitTransaction();
113114
}
114-
return new DropTableResult(tbl, success, tableDataShouldBeDeleted,
115+
return new DropTableResult(tblPath, success,
116+
tableDataShouldBeDeleted, isMustPurge(request.getEnvContext(), tbl),
115117
partPaths, ReplChangeManager.shouldEnableCm(db, tbl));
116118
} finally {
117119
if (!success) {
@@ -172,12 +174,12 @@ public String getOperationProgress() {
172174
void destroy() {
173175
super.destroy();
174176
tbl = null;
175-
tblPath = null;
176177
}
177178

178-
public record DropTableResult(Table table,
179+
public record DropTableResult(Path tablePath,
179180
boolean success,
180181
boolean tableDataShouldBeDeleted,
182+
boolean ifPurge,
181183
List<Path> partPaths,
182184
boolean shouldEnableCm) {
183185

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,16 +3087,13 @@ public AsyncOperationResp drop_table_req(DropTableRequest dropTableReq) throws M
30873087
// to ensure the data is deleted on the transaction committed,
30883088
// regardless of whether the operation has been aborted or not.
30893089
if (result != null && result.success() && result.tableDataShouldBeDeleted()) {
3090-
boolean ifPurge = isMustPurge(dropTableReq.getEnvContext(), result.table());
3090+
boolean ifPurge = result.ifPurge();
30913091
boolean shouldEnableCm = result.shouldEnableCm();
30923092
// Data needs deletion. Check if trash may be skipped.
30933093
// Delete the data in the partitions which have other locations
30943094
deletePartitionData(result.partPaths(), ifPurge, shouldEnableCm);
30953095
// Delete the data in the table
3096-
if (result.table().getSd().getLocation() != null) {
3097-
Path tablePath = new Path(result.table().getSd().getLocation());
3098-
deleteTableData(tablePath, ifPurge, shouldEnableCm);
3099-
}
3096+
deleteTableData(result.tablePath(), ifPurge, shouldEnableCm);
31003097
}
31013098
}
31023099
AsyncOperationResp resp = new AsyncOperationResp(status.getId());

0 commit comments

Comments
 (0)