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

br: fix get snapshot response pointer deref panic (#54510) #54712

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #54510

What problem does this PR solve?

Issue Number: close #54511

Problem Summary:

EC2 DescribeSnapshots API doesn't always return StateMessage in response for errored snapshot. Example response:

{
    "Snapshots": [
        {
            "Description": "",
            "Encrypted": true,
            "KmsKeyId": "...",
            "OwnerId": "...",
            "Progress": "99%",
            "SnapshotId": "snap-04c5f87d0a2b069b0",
            "StartTime": "2024-07-08T15:07:01.437000+00:00",
            "State": "error",
            "VolumeId": "vol-0377214577dd710de",
            "VolumeSize": 50,
            "Tags": [
                ...
            ],
            "StorageTier": "standard"
        }
    ]
}

In these cases, snapshot backup process panics due to nil pointer dereference. End result is the same (failed backup), but we still want to correctly process these errors

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4474931]

goroutine 1 [running]:
github.com/pingcap/tidb/br/pkg/aws.(*EC2Session).WaitSnapshotsCreated(0xc03e03f660, 0xc0073997d0, {0x5c81370, 0xc00c4a6b00})
  /tidb/br/pkg/aws/ebs.go:255 +0xa71
github.com/pingcap/tidb/br/pkg/task.RunBackupEBS({0x5c814f8, 0xc000193b80}, {0x5c940b8?, 0x86bcdc0?}, 0xc000c1fc00)
  /tidb/br/pkg/task/backup_ebs.go:255 +0x1c8a
main.runBackupCommand(0xc000c20000, {0x53bfc8f, 0xb})
  /tidb/br/cmd/br/backup.go:36 +0x1d4
main.newFullBackupCommand.func1(0xc00079a800?, {0xc000c480c0?, 0x4?, 0x53adfc5?})
  /tidb/br/cmd/br/backup.go:117 +0x1f
github.com/spf13/cobra.(*Command).execute(0xc000c20000, {0xc00026e030, 0xc, 0xc})
  /go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:916 +0x87c
github.com/spf13/cobra.(*Command).ExecuteC(0xc000c04000)
  /go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
  /go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
main.main()
  /tidb/br/cmd/br/main.go:36 +0x212

What changed and how does it work?

Check state message ptr is defined before deref

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

test panics prior to fix, success w/ fix

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: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added component/br This issue is related to BR of TiDB. ok-to-test release-note-none Denotes a PR that doesn't merit a release note. labels Jul 18, 2024
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels Jul 18, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jul 29, 2024
Copy link

ti-chi-bot bot commented Aug 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BornChanger, YuJuncen

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:

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

Copy link

ti-chi-bot bot commented Aug 28, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-28 06:01:05.394107704 +0000 UTC m=+936460.528557826: ☑️ agreed by BornChanger.
  • 2024-08-28 06:06:23.657272125 +0000 UTC m=+936778.791722247: ☑️ agreed by YuJuncen.

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-6.5@2c71fbb). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-6.5     #54712   +/-   ##
================================================
  Coverage               ?   73.6125%           
================================================
  Files                  ?       1097           
  Lines                  ?     352444           
  Branches               ?          0           
================================================
  Hits                   ?     259443           
  Misses                 ?      76306           
  Partials               ?      16695           

@ti-chi-bot ti-chi-bot bot merged commit 8607475 into pingcap:release-6.5 Aug 28, 2024
22 checks passed
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. component/br This issue is related to BR of TiDB. lgtm ok-to-test release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants