Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion scylla/src/client/caching_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,15 @@ where
stmt
};

if self.max_capacity == self.cache.len() {
// This loop was added to prevent a race condition (+ memory leak).
// When 2 threads enter this because cache is full, they may remove the same element,
// but add different ones. Then we get cache overflow.
// If we don't have a loop here, then this overflow would never disappear during typical
// operation of caching session.
// The loop has downsides: it could evict more entries than strictly necessary, or starve
// some thread for a bit. If this becomes a problem then maye we should research how
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in the comment: 'maye' should be 'maybe'.

Suggested change
// some thread for a bit. If this becomes a problem then maye we should research how
// some thread for a bit. If this becomes a problem then maybe we should research how

Copilot uses AI. Check for mistakes.

// some more robust caching crates are implemented?
while self.max_capacity <= self.cache.len() {
// Cache is full, remove the first entry
// Don't hold a reference into the map (that's why the to_string() is called)
// This is because the documentation of the remove fn tells us that it may deadlock
Expand Down
Loading