gavinchou commented on code in PR #60543:
URL: https://github.com/apache/doris/pull/60543#discussion_r2789496725
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/CloudTabletStatMgr.java:
##########
@@ -60,11 +101,42 @@ public CloudTabletStatMgr() {
@Override
protected void runAfterCatalogReady() {
LOG.info("cloud tablet stat begin");
- List<Long> dbIds = getAllTabletStats();
+ // get stats for active tablets
+ Set<Long> copiedTablets;
+ synchronized (activeTablets) {
+ copiedTablets = new HashSet<>(activeTablets);
+ activeTablets.clear();
+ }
+ getActiveTabletStats(copiedTablets);
+
+ // get stats by interval
+ List<Long> dbIds = getAllTabletStats(cloudTablet -> {
+ if (copiedTablets.contains(cloudTablet.getId())) {
+ return false;
+ }
+ List<Replica> replicas =
Env.getCurrentInvertedIndex().getReplicas(cloudTablet.getId());
+ if (replicas == null || replicas.isEmpty()) {
+ return false;
+ }
+ CloudReplica cloudReplica = (CloudReplica) replicas.get(0);
+ int index = cloudReplica.getStatsIntervalIndex();
+ if (index >= DEFAULT_INTERVAL_LADDER_MS.length) {
+ LOG.warn("get tablet stats interval index out of range,
tabletId: {}, index: {}",
+ cloudTablet.getId(), index);
+ index = DEFAULT_INTERVAL_LADDER_MS.length - 1;
+ }
+ long interval = DEFAULT_INTERVAL_LADDER_MS[index];
+ if (interval == Long.MAX_VALUE
+ || System.currentTimeMillis() -
cloudReplica.getLastGetTabletStatsTime() < interval) {
+ return false;
+ }
+ return true;
+ });
updateStatInfo(dbIds);
}
- private List<Long> getAllTabletStats() {
+ private List<Long> getAllTabletStats(Function<CloudTablet, Boolean>
filter) {
Review Comment:
should we add some kind mechanism like forcing get all tablet stats for
emergency or fallback to the original logic in case of bugs.
--
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]