-
Notifications
You must be signed in to change notification settings - Fork 273
Problem: memiavl don't support rewrite snapshot at background #959
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
Conversation
Closes: crypto-org-chain#948 Solution: - support copy-on-write on `MemNode`s - support snapshot rewrite at background, catch-up and switch in `Commit` event. better error handling temp fix build revert snapshot rewrite stuff for now
} | ||
|
||
func writeFileSync(name string, data []byte) error { | ||
f, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) |
Check failure
Code scanning / gosec
Potential file inclusion via variable
func (t *MultiTree) ApplyChangeSet(changeSets MultiChangeSet, updateCommitInfo bool) ([]byte, int64, error) { | ||
var version int64 | ||
if t.lastCommitInfo.Version == 0 && t.initialVersion > 1 { | ||
version = int64(t.initialVersion) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
panic("version overflows uint32") | ||
} | ||
|
||
v := uint32(initialVersion) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
fmt.Printf("snapshot loaded: %d %X\n", tree.Version(), tree.RootHash()) | ||
} else { | ||
tree = memiavl.NewWithInitialVersion(int64(initialVersion)) | ||
tree = memiavl.NewWithInitialVersion(uint32(initialVersion)) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
Signed-off-by: yihuang <huang@crypto.com>
Codecov Report
@@ Coverage Diff @@
## main #959 +/- ##
==========================================
+ Coverage 41.19% 43.07% +1.88%
==========================================
Files 62 62
Lines 4564 4722 +158
==========================================
+ Hits 1880 2034 +154
+ Misses 2455 2452 -3
- Partials 229 236 +7
|
@mmsqe Just did a big change to integrate WAL |
already using that, just using my fork for now, will open another PR to backport to 0.19.x EDIT: cosmos/iavl#732 |
return errors.Wrap(err, "read wal last index failed") | ||
} | ||
|
||
snapshotVersion := uint64(t.Version()) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
|
||
// RewriteSnapshot writes the current version of memiavl into a snapshot, and update the `current` symlink. | ||
func (db *DB) RewriteSnapshot() error { | ||
version := uint32(db.lastCommitInfo.Version) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
} | ||
} | ||
return &Tree{version: uint32(version), bwal: wal}, nil | ||
return &Tree{version: uint32(version)} |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
Co-authored-by: mmsqe <tqd0800210105@gmail.com> Signed-off-by: yihuang <huang@crypto.com>
Closes: #948
Solution:
MemNode
sCommit
event.👮🏻👮🏻👮🏻 !!!! 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! :)