Closed cool-develope closed 4 months ago
The updates involve refactoring the pruning logic of a Go application's V1. The changes focus on improving the handling of orphan nodes by introducing a new method to delete them and altering the existing pruning function to work asynchronously. This approach aims to enhance performance by preventing the main thread I/O from being blocked, and it also adds the flexibility to manually trigger the pruning process via an exposed API.
File(s) | Summary of Changes |
---|---|
nodedb.go |
- Added time package import- Added deleteOrphans method- Modified deleteLegacyVersions to use a goroutine and invoke deleteOrphans |
batch.go |
- Introduced sync.Mutex field mtx in the BatchWithFlusher struct- Modified Set and Delete methods to acquire and release the mutex for thread safety |
Objective | Addressed | Explanation |
---|---|---|
Refactor the pruning logic to handle orphan nodes more efficiently and allow manual triggering (Issue #862) | ✅ | The addition of deleteOrphans and the modification of deleteLegacyVersions to work asynchronously with a goroutine align with the objective of improving efficiency and allowing manual operation. |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?
Is this concurrency safe with main thread commits? (This can add to deleting while the main thread is committing right?)
Do we need a mutex to ensure the two don't try to add to batch at the same time?
Is this concurrency safe with main thread commits? (This can add to deleting while the main thread is committing right?)
Do we need a mutex to ensure the two don't try to add to batch at the same time?
yeah, the test is failed with data racing
This is the wrong spot to put it, we hacked something that worked in this branch https://github.com/cosmos/iavl/tree/dev/v1.0.0-orphan
(the first part of the loop is what was expensive)
I think the way you were doing the code is cleaner, just that was something that I got to work. Plz feel free to takeover/move anything that helps :pray:
close in favor of #877
Closes: #862
Context
BatchWithFlusher
to avoid the race condition