-
Notifications
You must be signed in to change notification settings - Fork 102
lightning: fix the bug that calculate unfinished ranges may miss some range #1413
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
rest LGTM |
pkg/lightning/backend/local/local.go
Outdated
} | ||
|
||
// copy the ranges because we may change its values | ||
ranges := make([]Range, 0, len(rawRanges)) | ||
ranges = append(ranges, rawRanges...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe can use built-in copy function
if bytes.Compare(fr.end, start) > 0 { | ||
start = fr.end | ||
} | ||
if bytes.Compare(fr.end, end) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if bytes.Compare(fr.end, end) > 0 { | |
if bytes.Compare(fr.end, end) >= 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no difference between > and >= in this context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. For >=
, we can exit the loop early when fr.end == end
.
/merge |
This pull request has been accepted and is ready to merge. Commit hash: e68fc55
|
In response to a cherrypick label: new pull request created: #1416. |
What problem does this PR solve?
Fix the bug that lightning local backend may encounter data loss.
Close #1403
What is changed and how it works?
writeAndIngestByRanges
to fail fast to avoid waiting some much time when met unrecoverable failure.Check List
Tests
Code changes
Side effects
Related changes
Release note