github-actions[bot] commented on code in PR #68282:
URL: https://github.com/apache/doris/pull/68282#discussion_r4256994607


##########
fe/fe-core/src/main/java/org/apache/doris/statistics/analysis/TableStatsMeta.java:
##########
@@ -130,6 +140,94 @@ public TableStatsMeta(long rowCount, AnalysisInfo 
analyzedJob, TableIf table) {
         update(analyzedJob, table);
     }
 
+    /**
+     * Create a record for a table which doesn't have one yet, in the state of 
an empty table. The rows
+     * loaded into the table are accumulated by {@link 
AnalysisManager#replayUpdateRowsRecord}, so a record
+     * has to exist before the first load, otherwise these rows can never be 
turned into a row count.
+     */
+    public TableStatsMeta(OlapTable table) {

Review Comment:
   [P3] Keep empty records from marking tables as analyzed
   
   StatisticsMetricCollector increments statistics_not_analyzed_table_num only 
when findTableStatsStatus(tableId) is null (lines 89-91). A nonempty table that 
has never been analyzed therefore stops contributing to that gauge as soon as 
TRUNCATE creates this empty record, even though it still has no column stats or 
analysis timestamp. Update the metric's consumer to distinguish this retained 
empty state from analyzed or user-injected statistics; otherwise the dashboard 
undercounts tables needing their first analysis.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableStatsCommand.java:
##########
@@ -242,28 +242,37 @@ public ShowResultSet 
constructTableResultSet(TableStatsMeta tableStatistic, Tabl
         row.add(String.valueOf(tableStatistic.updatedRows));
         row.add(String.valueOf(tableStatistic.queriedTimes.get()));
         row.add(String.valueOf(tableStatistic.rowCount));
-        LocalDateTime dateTime =
-                
LocalDateTime.ofInstant(Instant.ofEpochMilli(tableStatistic.updatedTime),
-                java.time.ZoneId.systemDefault());
-        LocalDateTime lastAnalyzeTime =
-                
LocalDateTime.ofInstant(Instant.ofEpochMilli(tableStatistic.lastAnalyzeTime),
-                java.time.ZoneId.systemDefault());
-        row.add(dateTime.format(formatter));
+        row.add(formatStatsTime(tableStatistic.updatedTime, formatter));
         Set<Pair<String, String>> columnsSet = tableStatistic.analyzeColumns();
         Set<Pair<String, String>> newColumnsSet = new HashSet<>();
         for (Pair<String, String> pair : columnsSet) {
             
newColumnsSet.add(Pair.of(Util.getTempTableDisplayName(pair.first), 
pair.second));
         }
         row.add(newColumnsSet.toString());
-        row.add(tableStatistic.jobType.toString());
+        // A record which was not created by an analyze job, e.g. the record 
kept by TRUNCATE TABLE, has no
+        // trigger to show.
+        row.add(tableStatistic.jobType == null ? "" : 
tableStatistic.jobType.toString());

Review Comment:
   [P2] Read the nullable trigger once when showing table stats
   
   SHOW TABLE STATS holds neither the table lock nor this record's monitor. On 
a previously analyzed table, the first jobType read here can be non-null, then 
a concurrent TRUNCATE TABLE runs TableStatsMeta.reset() and sets the same 
retained record's jobType to null before the second read calls toString(). The 
SHOW statement then fails with NullPointerException despite the null guard. 
Capture jobType once in a local variable, or read a snapshot under the record 
monitor.



-- 
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]

Reply via email to