[
https://issues.apache.org/jira/browse/HIVE-25900?focusedWorklogId=717780&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-717780
]
ASF GitHub Bot logged work on HIVE-25900:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 31/Jan/22 07:15
Start Date: 31/Jan/22 07:15
Worklog Time Spent: 10m
Work Description: kasakrisz commented on a change in pull request #2984:
URL: https://github.com/apache/hive/pull/2984#discussion_r795393121
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java
##########
@@ -139,109 +200,262 @@ public void init() {
}
}
- public void init(Hive db) {
+ private static void init(Hive db) {
final boolean dummy =
db.getConf().get(HiveConf.ConfVars.HIVE_SERVER2_MATERIALIZED_VIEWS_REGISTRY_IMPL.varname)
.equals("DUMMY");
if (dummy) {
// Dummy registry does not cache information and forwards all requests
to metastore
- initialized.set(true);
+ SINGLETON = new MaterializedViewsRegistry() {};
LOG.info("Using dummy materialized views registry");
} else {
+ SINGLETON = new
InMemoryMaterializedViewsRegistry(HiveMaterializedViewsRegistry::createMaterialization);
// We initialize the cache
long period = HiveConf.getTimeVar(db.getConf(),
ConfVars.HIVE_SERVER2_MATERIALIZED_VIEWS_REGISTRY_REFRESH, TimeUnit.SECONDS);
+ if (period <= 0) {
+ return;
+ }
+
ScheduledExecutorService pool =
Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("HiveMaterializedViewsRegistry-%d")
.build());
- pool.scheduleAtFixedRate(new Loader(db), 0, period, TimeUnit.SECONDS);
+
+ MaterializedViewObjects objects =
db::getAllMaterializedViewObjectsForRewriting;
+ pool.scheduleAtFixedRate(new Loader(db.getConf(), SINGLETON, objects),
0, period, TimeUnit.SECONDS);
}
}
- private class Loader implements Runnable {
- private final Hive db;
+ public interface MaterializedViewObjects {
+ List<Table> getAllMaterializedViewObjectsForRewriting() throws
HiveException;
+ }
- private Loader(Hive db) {
- this.db = db;
+ public static class Loader implements Runnable {
Review comment:
Changed to package private.
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 717780)
Time Spent: 1.5h (was: 1h 20m)
> Materialized view registry does not clean non existing views at refresh
> -----------------------------------------------------------------------
>
> Key: HIVE-25900
> URL: https://issues.apache.org/jira/browse/HIVE-25900
> Project: Hive
> Issue Type: Bug
> Components: Materialized views
> Reporter: Krisztian Kasa
> Assignee: Krisztian Kasa
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> CBO plans of materialized views which are enabled for query rewrite are
> cached in HS2 (MaterializedViewsCache, HiveMaterializedViewsRegistry)
> The registry is refreshed periodically from HMS:
> {code:java}
> set hive.server2.materializedviews.registry.refresh.period=1500s;
> {code}
> This functionality is required when multiple HS2 instances are used in a
> cluster: MV drop operation is served by one of the HS2 instances and the
> registry is updated at that time in that instance. However other HS2
> instances still cache the non-existent view and need to be refreshed by the
> updater thread.
> Currently the updater thread adds new entries, refresh existing ones but does
> not remove the outdated entries.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)