Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

pkg/lightning: make save file checkpoint more compatible to avoid checkpoint data loss (#885) #889

Merged
merged 2 commits into from
Mar 18, 2021

Conversation

ti-srebot
Copy link
Contributor

@ti-srebot ti-srebot commented Mar 17, 2021

cherry-pick #885 to release-4.0
You can switch your code base to this Pull Request by using git-extras:

# In br repo:
git pr https://github.com/pingcap/br/pull/889

After apply modifications, you can push your change to this PR via:

git push [email protected]:ti-srebot/br.git pr/889:release-4.0-d95f9fdfcd29

What problem does this PR solve?

Currently, lightning use ioutil.WriteFile to save checkpoint file, which can lead to data loss if lightning exit before the file is fully writen.

What is changed and how it works?

First write checkpoint content to a temp file and then replace it to the target file.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch

Release Note

  • Fix a bug that lightning unexpected exit may cause checkpoint file truncated to 0 sized.

@kennytm
Copy link
Collaborator

kennytm commented Mar 17, 2021

/lgtm

@ti-srebot ti-srebot added the status/LGT1 LGTM1 label Mar 17, 2021
@lance6716
Copy link
Contributor

/lgtm

@ti-srebot ti-srebot added status/LGT2 LGTM2 and removed status/LGT1 LGTM1 labels Mar 17, 2021
@kennytm
Copy link
Collaborator

kennytm commented Mar 17, 2021

/run-integration-test

@glorv glorv merged commit 309e6ef into pingcap:release-4.0 Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants