Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The statistics metric cannot correctly display the stats health #57176

Open
Rustin170506 opened this issue Nov 6, 2024 · 2 comments · Fixed by #57555
Open

The statistics metric cannot correctly display the stats health #57176

Rustin170506 opened this issue Nov 6, 2024 · 2 comments · Fixed by #57555
Assignees
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/statistics severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@Rustin170506
Copy link
Member

Rustin170506 commented Nov 6, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Create a tidb cluster
  2. Create 1000 tables
  3. Check the grafana

2. What did you expect to see? (Required)

The stats health is correct.

3. What did you see instead (Required)

image
| test    | sbtest604  |                |      89 |
| test    | sbtest875  |                |      90 |
| test    | sbtest419  |                |      89 |
| test    | sbtest746  |                |      89 |
| test    | sbtest896  |                |      89 |
+---------+------------+----------------+---------+
1000 rows in set (0.01 sec)

Introduce by #56475

// UpdateStatsHealthyMetrics updates stats healthy distribution metrics according to stats cache.
func (s *StatsCacheImpl) UpdateStatsHealthyMetrics() {
	distribution := make([]int64, 9)
	uneligibleAnalyze := 0
	for _, tbl := range s.Values() {
-		distribution[4]++ // total table count
+ 		distribution[7]++ // total table count
		isEligibleForAnalysis := tbl.IsEligibleForAnalysis()
		if !isEligibleForAnalysis {
			uneligibleAnalyze++
			continue
		}
		healthy, ok := tbl.GetStatsHealthy()
		if !ok {
			continue
		}
		if healthy < 50 {
			distribution[0]++
		} else if healthy < 55 {
			distribution[1]++
		} else if healthy < 60 {
			distribution[2]++
		} else if healthy < 70 {
			distribution[3]++
		} else if healthy < 80 {
			distribution[4]++
		} else if healthy < 100 {
			distribution[5]++
		} else {
			distribution[6]++
		}
	}
	for i, val := range distribution {
		handle_metrics.StatsHealthyGauges[i].Set(float64(val))
	}
	handle_metrics.StatsHealthyGauges[8].Set(float64(uneligibleAnalyze))
}

4. What is your TiDB version? (Required)

master

@Rustin170506 Rustin170506 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner component/statistics severity/moderate labels Nov 6, 2024
@Rustin170506 Rustin170506 changed the title The statistics metric cannot correctly display the system's health The statistics metric cannot correctly display the stats health Nov 6, 2024
@hawkingrei hawkingrei self-assigned this Nov 6, 2024
@Rustin170506
Copy link
Member Author

The unneeded table number was also wrong. Maybe it was affected by the system tables.

@ti-chi-bot ti-chi-bot bot closed this as completed in d8c9190 Nov 20, 2024
@ti-chi-bot ti-chi-bot bot added the affects-8.5 This bug affects the 8.5.x(LTS) versions. label Nov 20, 2024
@ti-chi-bot ti-chi-bot bot added the affects-7.5 This bug affects the 7.5.x(LTS) versions. label Nov 29, 2024
@Rustin170506
Copy link
Member Author

The unneeded table number was also wrong. Maybe it was affected by the system tables.

reopen

@Rustin170506 Rustin170506 reopened this Dec 2, 2024
@Rustin170506 Rustin170506 moved this to 📋 Backlog in 😆Stats Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/statistics severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants