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

planner: fix potential panic when generating hints in statement summary (#46312) #46393

Merged

Conversation

ti-chi-bot
Copy link
Member

@ti-chi-bot ti-chi-bot commented Aug 24, 2023

This is an automated cherry-pick of #46312

What problem does this PR solve?

Issue Number: close #46311

Problem Summary:
Use empty slices to init PlannerSelectBlockAsName to avoid panic when dereferencing.

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  1. create a cluster
  2. run script like
func main() {
	cfg := &config{}
	cfg.parse()
	connStr := cfg.db + "?maxAllowedPacket=512000000&charset=utf8mb4&parseTime=True&loc=Local&allowAllFiles=true"
	var wg sync.WaitGroup
	for i := 0; i < 100; i++ {
		wg.Add(1)
		go func() {
			db, err := sql.Open("mysql", connStr)
			if err != nil {
				log.Fatal(err)
			}
			defer db.Close()

			stmt, err := db.Prepare("select t.i, t.j from t, t1 where t.k = 0")
			if err != nil {
				log.Fatal(err)
			}

			stmt1, err := db.Prepare("select t.i, t.j from t, t1 where t.i = 0")
			if err != nil {
				log.Fatal(err)
			}

			for {
				rs, err := stmt.Query()
				if err != nil {
					log.Println(err)
					break
				}
				for rs.Next() {
					var i int
					var j int
					err = rs.Scan(&i, &j)
					if err != nil {
						log.Println(err)
						break
					}
					log.Println(i, j)
				}
				rs.Close()

				rs1, err := stmt1.Query()
				if err != nil {
					log.Println(err)
					break
				}
				for rs1.Next() {
					var i int
					var j int
					err = rs1.Scan(&i, &j)
					if err != nil {
						log.Println(err)
						break
					}
					log.Println(i, j)
				}
				rs1.Close()
			}
			wg.Done()
		}()
	}
	wg.Wait()
}
  1. check the panic log in tidb-server (I cannot reproduce the panic mentioned in the issue before PR.)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: Jack Yu <jackysp@gmail.com>
Signed-off-by: Jack Yu <jackysp@gmail.com>
@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/cherry-pick-for-release-7.1 This PR is cherry-picked to release-7.1 from a source PR. labels Aug 24, 2023
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 24, 2023
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Aug 24, 2023
@ti-chi-bot ti-chi-bot bot added the lgtm label Aug 24, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 24, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, jackysp

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Defined2014,jackysp]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 24, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 24, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-08-24 07:09:29.231127279 +0000 UTC m=+1392533.780143265: ☑️ agreed by jackysp.
  • 2023-08-24 08:11:51.242425688 +0000 UTC m=+1396275.791441675: ☑️ agreed by Defined2014.

@Defined2014
Copy link
Contributor

/test check-dev

@tiprow
Copy link

tiprow bot commented Aug 24, 2023

@Defined2014: No presubmit jobs available for pingcap/tidb@release-7.1

In response to this:

/test check-dev

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit a52c366 into pingcap:release-7.1 Aug 24, 2023
@codecov
Copy link

codecov bot commented Aug 24, 2023

Codecov Report

❗ No coverage uploaded for pull request base (release-7.1@b19b65c). Click here to learn what that means.
The diff coverage is n/a.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-7.1     #46393   +/-   ##
================================================
  Coverage               ?   73.4273%           
================================================
  Files                  ?       1203           
  Lines                  ?     376587           
  Branches               ?          0           
================================================
  Hits                   ?     276518           
  Misses                 ?      82407           
  Partials               ?      17662           

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/cherry-pick-for-release-7.1 This PR is cherry-picked to release-7.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants