This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 6ad6e55d27cd20096f2c706794dca05576167909 Author: Jibing-Li <[email protected]> AuthorDate: Thu Aug 17 15:20:02 2023 +0800 [Fix](statistics)Fix update cached column stats bug (#23049) `show column cached stats` sometimes show wrong min/max value: ``` mysql> show column cached stats hive.tpch100.region; +-------------+-------+------+----------+-----------+---------------+------+------+--------------+ | column_name | count | ndv | num_null | data_size | avg_size_byte | min | max | updated_time | +-------------+-------+------+----------+-----------+---------------+------+------+--------------+ | r_regionkey | 5.0 | 5.0 | 0.0 | 24.0 | 4.0 | N/A | N/A | null | | r_comment | 5.0 | 5.0 | 0.0 | 396.0 | 66.0 | N/A | N/A | null | | r_name | 5.0 | 5.0 | 0.0 | 40.8 | 6.8 | N/A | N/A | null | +-------------+-------+------+----------+-----------+---------------+------+------+--------------+ ``` This pr is to fix this bug. It is because while transferring ColumnStatistic object to JSON, it doesn't contain the minExpr and maxExpr attribute. --- .../java/org/apache/doris/service/FrontendServiceImpl.java | 10 +++++++--- .../main/java/org/apache/doris/statistics/StatisticsCache.java | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java index 88bc68bc07..4043114051 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java @@ -75,7 +75,6 @@ import org.apache.doris.qe.MasterCatalogExecutor; import org.apache.doris.qe.QeProcessorImpl; import org.apache.doris.qe.QueryState; import org.apache.doris.qe.VariableMgr; -import org.apache.doris.statistics.ColumnStatistic; import org.apache.doris.statistics.StatisticsCacheKey; import org.apache.doris.statistics.query.QueryStats; import org.apache.doris.system.Backend; @@ -2755,8 +2754,13 @@ public class FrontendServiceImpl implements FrontendService.Iface { @Override public TStatus updateStatsCache(TUpdateFollowerStatsCacheRequest request) throws TException { StatisticsCacheKey key = GsonUtils.GSON.fromJson(request.key, StatisticsCacheKey.class); - ColumnStatistic columnStatistic = GsonUtils.GSON.fromJson(request.colStats, ColumnStatistic.class); - Env.getCurrentEnv().getStatisticsCache().putCache(key, columnStatistic); + /* + TODO: Need to handle minExpr and maxExpr, so that we can generate the columnStatistic + here and use putCache to update cached directly. + ColumnStatistic columnStatistic = GsonUtils.GSON.fromJson(request.colStats, ColumnStatistic.class); + Env.getCurrentEnv().getStatisticsCache().putCache(key, columnStatistic); + */ + Env.getCurrentEnv().getStatisticsCache().refreshColStatsSync(key.tableId, key.idxId, key.colName); return new TStatus(TStatusCode.OK); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsCache.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsCache.java index fdb3bb221a..27756dcc3f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsCache.java +++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsCache.java @@ -240,6 +240,10 @@ public class StatisticsCache { updateFollowerStatsCacheRequest.key = GsonUtils.GSON.toJson(k); updateFollowerStatsCacheRequest.colStats = GsonUtils.GSON.toJson(c); for (Frontend frontend : Env.getCurrentEnv().getFrontends(FrontendNodeType.FOLLOWER)) { + if (frontend.getHost().equals(Env.getCurrentEnv().getSelfNode().getHost())) { + // Doesn't need to send request to current node. + continue; + } TNetworkAddress address = new TNetworkAddress(frontend.getHost(), frontend.getRpcPort()); FrontendService.Client client = null; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
