deniskuzZ commented on code in PR #6961:
URL: https://github.com/apache/hive/pull/6961#discussion_r4644208814
##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -218,17 +229,34 @@ public Table getTable(GetTableRequest req) throws
TException {
tableId = (long) queryCache.get(cacheKeyTableId);
}
+ // a table missing from the metastore stays missing for the rest of the
compilation
+ CacheKey cacheKeyNotFound = tableNotFoundKey(req.getCatName(),
req.getDbName(), req.getTblName());
+ String notFound = (String) queryCache.get(cacheKeyNotFound);
+ if (notFound != null) {
+ LOG.debug("Query level HMS cache: method=getTable, table not found,
dbName={}, tblName={}",
+ req.getDbName(), req.getTblName());
+ throw new NoSuchObjectException(notFound);
+ }
+
req.setId(tableId);
CacheKey cacheKey = new CacheKey(KeyType.TABLE, req);
Table table = (Table) queryCache.get(cacheKey);
if (table == null) {
- table = delegate.getTable(req);
+ try {
+ table = delegate.getTable(req);
+ } catch (NoSuchObjectException e) {
+ queryCache.put(cacheKeyNotFound, String.valueOf(e.getMessage()));
Review Comment:
A CTAS or CREATE TABLE target is looked up at compile time
(CreateTableAnalyzer calls getTable(..., false)), so this caches it as not
found. Executor disables the query cache during runTasks, so the createTable at
execution can't remove the entry (line 736), and then re-enables the cache for
postExecutionActions. A post-exec hook that looks up the new table by name then
gets NoSuchObjectException.
Could the not-found entries be dropped when execution starts, or this
negative cache be limited to compilation?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]