-
Notifications
You must be signed in to change notification settings - Fork 241
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
Problem: memiavl don't support rollback #1091
Conversation
Closes: crypto-org-chain#1089 Update CHANGELOG.md Signed-off-by: yihuang <[email protected]> Update memiavl/db.go Signed-off-by: yihuang <[email protected]> revert int type changes
@@ -24,7 +24,7 @@ | |||
if height > math.MaxUint32 { | |||
return snapshottypes.SnapshotItem{}, fmt.Errorf("version overflows uint32: %d", height) | |||
} | |||
snapshotDir := snapshotName(uint32(height)) | |||
snapshotDir := snapshotName(int64(height)) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
@@ -46,7 +47,7 @@ | |||
if int64(version) > curVersion { | |||
return fmt.Errorf("snapshot is not created yet: height: %d", version) | |||
} | |||
mtree, err = LoadMultiTree(snapshotPath(db.dir, version), true, 0) | |||
mtree, err = LoadMultiTree(filepath.Join(db.dir, snapshotName(int64(version))), true, 0) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
found bool | ||
) | ||
if err := traverseSnapshots(root, false, func(version int64) (bool, error) { | ||
if version <= int64(targetVersion) { |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
|
||
// prune snapshots that's larger than the target version | ||
if err := traverseSnapshots(dir, false, func(version int64) (bool, error) { | ||
if version <= int64(opts.TargetVersion) { |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
|
||
// truncate the WAL | ||
opts.Logger.Info("truncate WAL from back, version: %d", opts.TargetVersion) | ||
if err := wal.TruncateBack(walIndex(int64(opts.TargetVersion), mtree.initialVersion)); err != nil { |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
Codecov Report
@@ Coverage Diff @@
## main #1091 +/- ##
==========================================
+ Coverage 46.18% 46.55% +0.36%
==========================================
Files 80 80
Lines 7195 7250 +55
==========================================
+ Hits 3323 3375 +52
+ Misses 3516 3514 -2
- Partials 356 361 +5
|
Co-authored-by: mmsqe <[email protected]> Signed-off-by: yihuang <[email protected]>
Co-authored-by: mmsqe <[email protected]> Signed-off-by: yihuang <[email protected]>
Co-authored-by: mmsqe <[email protected]> Signed-off-by: yihuang <[email protected]>
Closes: #1089
👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻
PR Checklist:
make
)make test
)go fmt
)golangci-lint run
)go list -json -m all | nancy sleuth
)Thank you for your code, it's appreciated! :)