dracoooooo commented on code in PR #1566:
URL: https://github.com/apache/horaedb/pull/1566#discussion_r1757319079
##########
src/wal/src/local_storage_impl/segment.rs:
##########
@@ -383,10 +465,13 @@ pub struct SegmentManager {
all_segments: Mutex<HashMap<u64, Arc<Mutex<Segment>>>>,
/// Cache for opened segments
- cache: Mutex<VecDeque<u64>>,
+ cache: Mutex<VecDeque<(u64, Arc<Mutex<Segment>>)>>,
Review Comment:
The `u64` in this tuple represents the segment ID. The reason for storing it
is to determine if a segment exists in the cache without needing to acquire the
lock for that segment. The newly added `Arc<Mutex<Segment>>` is to remove the
original `SegmentManager::get_segment` method, which is redundant and may cause
deadlock.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]