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

Merged

Conversation

michaelmdeng
Copy link
Contributor

@michaelmdeng michaelmdeng commented Jul 8, 2024

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
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test labels Jul 8, 2024
Copy link

ti-chi-bot bot commented Jul 8, 2024

Hi @michaelmdeng. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

Copy link

tiprow bot commented Jul 8, 2024

Hi @michaelmdeng. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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-sigs/prow repository.

@BornChanger
Copy link
Contributor

/ok-to-test

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.4310%. Comparing base (7a0611f) to head (b1035ed).
Report is 81 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54510         +/-   ##
=================================================
- Coverage   72.9116%   57.4310%   -15.4806%     
=================================================
  Files          1542       1674        +132     
  Lines        435991     624368     +188377     
=================================================
+ Hits         317888     358581      +40693     
- Misses        98569     241985     +143416     
- Partials      19534      23802       +4268     
Flag Coverage Δ
integration 38.1544% <0.0000%> (?)
unit 72.6288% <100.0000%> (+0.6954%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 62.4351% <100.0000%> (+16.3236%) ⬆️
@michaelmdeng
Copy link
Contributor Author

/retest

Copy link
Contributor

@YuJuncen YuJuncen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Co-authored-by: BornChanger <97348524+BornChanger@users.noreply.github.com>
Copy link

ti-chi-bot bot commented Jul 16, 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 Jul 16, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-15 10:40:41.359478607 +0000 UTC m=+264063.350420078: ☑️ agreed by YuJuncen.
  • 2024-07-16 01:25:51.076257193 +0000 UTC m=+317173.067198662: ☑️ agreed by BornChanger.
@BornChanger
Copy link
Contributor

/retest

Copy link

tiprow bot commented Jul 18, 2024

@michaelmdeng: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow b1035ed link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot merged commit 035f79e into pingcap:master Jul 18, 2024
31 of 32 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #54712.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 18, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #54713.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 18, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 18, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #54714.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants