Skip to content

Commit 0daab9d

Browse files
committed
fix-1
1 parent 2cc2573 commit 0daab9d

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,7 @@ public TruncateTableResponse truncate_table_req(TruncateTableRequest req)
27542754
.defaultMetaException();
27552755
} finally {
27562756
endFunction("truncate_table_req", success, ex,
2757-
TableName.getQualified(parsedDbName[CAT_NAME],parsedDbName[DB_NAME], req.getTableName()));
2757+
TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], req.getTableName()));
27582758
}
27592759
}
27602760

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
public abstract class AbstractRequestHandler<T extends TBase, A extends AbstractRequestHandler.Result> {
6161
private static final Logger LOG = LoggerFactory.getLogger(AbstractRequestHandler.class);
6262
private static final Map<String, AbstractRequestHandler> ID_TO_HANDLER = new ConcurrentHashMap<>();
63-
private static final AtomicLong ID = new AtomicLong(0);
63+
private static final AtomicLong ID_GEN = new AtomicLong(0);
6464
private static final ScheduledExecutorService REQUEST_CLEANER = Executors.newScheduledThreadPool(1, r -> {
6565
Thread thread = new Thread(r);
6666
thread.setDaemon(true);
@@ -113,7 +113,7 @@ private AbstractRequestHandler(String id) {
113113
}
114114

115115
AbstractRequestHandler(IHMSHandler handler, boolean async, T request) {
116-
this.id = UUID.randomUUID() + "-" + ID.incrementAndGet();
116+
this.id = UUID.randomUUID() + "-" + ID_GEN.incrementAndGet();
117117
this.handler = handler;
118118
this.request = request;
119119
this.async = async;
@@ -337,8 +337,8 @@ public boolean success() throws TException {
337337
* @return the alias, null or empty if no need to measure the operation.
338338
*/
339339
private String getMetricAlias() {
340-
RequestHandler handler = getClass().getAnnotation(RequestHandler.class);
341-
return handler != null ? handler.metricAlias() : null;
340+
RequestHandler rh = getClass().getAnnotation(RequestHandler.class);
341+
return rh != null ? rh.metricAlias() : null;
342342
}
343343

344344
public void checkInterrupted() throws MetaException {

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public class DropDatabaseHandler
8181
private List<String> packages;
8282
private AtomicReference<String> progress;
8383
private DropDatabaseResult result;
84+
private RawStore rs;
8485

8586
DropDatabaseHandler(IHMSHandler handler, DropDatabaseRequest request) {
8687
super(handler, request.isAsyncDrop(), request);
@@ -89,7 +90,6 @@ public class DropDatabaseHandler
8990
public DropDatabaseResult execute() throws TException, IOException {
9091
boolean success = false;
9192
Map<String, String> transactionalListenerResponses = Collections.emptyMap();
92-
RawStore rs = handler.getMS();
9393
rs.openTransaction();
9494
try {
9595
if (MetaStoreUtils.isDatabaseRemote(db)) {
@@ -154,6 +154,7 @@ public DropDatabaseResult execute() throws TException, IOException {
154154
}
155155
}
156156

157+
progress.set("Dropping the database");
157158
if (rs.dropDatabase(catalogName, name)) {
158159
if (!handler.getTransactionalListeners().isEmpty()) {
159160
checkInterrupted();
@@ -196,7 +197,7 @@ protected void beforeExecute() throws TException, IOException {
196197
this.catalogName = normalizeIdentifier(
197198
request.isSetCatalogName() ? request.getCatalogName() : MetaStoreUtils.getDefaultCatalog(handler.getConf()));
198199

199-
RawStore rs = handler.getMS();
200+
this.rs = handler.getMS();
200201
db = rs.getDatabase(catalogName, name);
201202
if (!MetastoreConf.getBoolVar(handler.getConf(), HIVE_IN_TEST) && ReplChangeManager.isSourceOfReplication(db)) {
202203
throw new InvalidOperationException("can not drop a database which is a source of replication");
@@ -414,6 +415,9 @@ protected void afterExecute(DropDatabaseResult result) throws MetaException, IOE
414415
wh.addToChangeManagement(funcCmPath);
415416
}
416417
if (request.isDeleteData()) {
418+
progress.set(String.format("Deleting %d partition paths and %d table paths from the database",
419+
result.getPartitionPaths() != null ? result.getPartitionPaths().size() : 0,
420+
result.getTablePaths().size()));
417421
Database db = result.getDatabase();
418422
// Delete the data in the partitions which have other locations
419423
List<Path> pathsToDelete = new ArrayList<>();
@@ -453,12 +457,16 @@ protected void afterExecute(DropDatabaseResult result) throws MetaException, IOE
453457
}
454458
}
455459
} finally {
460+
super.afterExecute(result);
461+
if (async) {
462+
rs.shutdown();
463+
}
464+
rs = null;
456465
tables = null;
457466
functions = null;
458467
procedures = null;
459468
packages = null;
460469
db = null;
461-
super.afterExecute(result);
462470
}
463471
}
464472
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class DropTableHandler
6565
private TableName tableName;
6666
private boolean tableDataShouldBeDeleted;
6767
private AtomicReference<String> progress;
68+
private RawStore ms;
6869

6970
DropTableHandler(IHMSHandler handler, DropTableRequest request) {
7071
super(handler, request.isAsyncDrop(), request);
@@ -74,9 +75,8 @@ public DropTableResult execute() throws TException {
7475
boolean success = false;
7576
List<Path> partPaths = null;
7677
Map<String, String> transactionalListenerResponses = Collections.emptyMap();
77-
Database db = null;
78+
Database db;
7879
boolean isReplicated = false;
79-
RawStore ms = handler.getMS();
8080
try {
8181
ms.openTransaction();
8282
String catName = tableName.getCat();
@@ -145,6 +145,7 @@ public void beforeExecute() throws TException, IOException {
145145
request.isSetCatalogName() ? request.getCatalogName() : getDefaultCatalog(handler.getConf()));
146146
String name = normalizeIdentifier(request.getTableName());
147147
String dbname = normalizeIdentifier(request.getDbName());
148+
this.ms = handler.getMS();
148149
tableName = new TableName(catName, dbname, name);
149150
progress = new AtomicReference<>("Starting to drop the table: " + tableName);
150151
GetTableRequest req = new GetTableRequest(tableName.getDb(), tableName.getTable());
@@ -197,6 +198,8 @@ protected void afterExecute(DropTableResult result) throws MetaException, IOExce
197198
// Data needs deletion. Check if trash may be skipped.
198199
// Delete the data in the partitions which have other locations
199200
List<Path> pathsToDelete = new ArrayList<>();
201+
progress.set(String.format("Deleting %d partition paths from the table",
202+
result.partPaths != null ? result.partPaths.size() : 0));
200203
if (result.partPaths != null) {
201204
pathsToDelete.addAll(result.partPaths);
202205
}
@@ -207,6 +210,10 @@ protected void afterExecute(DropTableResult result) throws MetaException, IOExce
207210
}
208211
} finally {
209212
super.afterExecute(result);
213+
if (async) {
214+
ms.shutdown();
215+
}
216+
ms = null;
210217
tbl = null;
211218
}
212219
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,13 @@ private void alterPartitionsForTruncate() throws TException {
180180
boolean shouldSendSingleEvent = MetastoreConf.getBoolVar(handler.getConf(),
181181
MetastoreConf.ConfVars.NOTIFICATION_ALTER_PARTITIONS_V2_ENABLED);
182182
if (shouldSendSingleEvent) {
183-
MetaStoreListenerNotifier.notifyEvent(handler.getTransactionalListeners(), EventMessage.EventType.ALTER_PARTITIONS,
183+
MetaStoreListenerNotifier.notifyEvent(handler.getTransactionalListeners(),
184+
EventMessage.EventType.ALTER_PARTITIONS,
184185
new AlterPartitionsEvent(partitions, partitions, table, true, true, handler), environmentContext);
185186
} else {
186187
for (Partition partition : partitions) {
187-
MetaStoreListenerNotifier.notifyEvent(handler.getTransactionalListeners(), EventMessage.EventType.ALTER_PARTITION,
188+
MetaStoreListenerNotifier.notifyEvent(handler.getTransactionalListeners(),
189+
EventMessage.EventType.ALTER_PARTITION,
188190
new AlterPartitionEvent(partition, partition, table, true, true, partition.getWriteId(), handler),
189191
environmentContext);
190192
}
@@ -260,15 +262,16 @@ private void truncateDataFiles(Path location, boolean isSkipTrash, boolean needC
260262
}
261263

262264
/**
263-
* Add an empty baseDir with a truncate metadatafile
265+
* Add an empty baseDir with a truncate metadatafile.
264266
* @param location partition or table directory
265267
* @param writeId allocated writeId
266268
* @throws MetaException
267269
*/
268270
public static void addTruncateBaseFile(Path location, long writeId, Configuration conf,
269271
AcidMetaDataFile.DataFormat dataFormat) throws MetaException {
270-
if (location == null)
272+
if (location == null) {
271273
return;
274+
}
272275

273276
Path basePath = new Path(location, AcidConstants.baseDir(writeId));
274277
try {

0 commit comments

Comments
 (0)