Skip to content

Commit

Permalink
Fix deadlock issue in CleanMessagesExecutor (#898)
Browse files Browse the repository at this point in the history
This commit resolves a deadlock by acquiring a write lock on the system
once instead of multiple times within the CleanMessagesExecutor. The
redundant system.write() calls have been removed, ensuring that the
metrics are updated without the need for additional locks.

This closes #897.
  • Loading branch information
hubcio committed Apr 12, 2024
1 parent b4308e8 commit 9e180ad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "server"
version = "0.2.17"
version = "0.2.18"
edition = "2021"
build = "src/build.rs"

Expand Down
6 changes: 2 additions & 4 deletions server/src/channels/commands/clean_messages.rs
Expand Up @@ -65,8 +65,8 @@ impl MessagesCleaner {
impl ServerCommand<CleanMessagesCommand> for CleanMessagesExecutor {
async fn execute(&mut self, system: &SharedSystem, _command: CleanMessagesCommand) {
let now = IggyTimestamp::now().to_micros();
let system_read = system.read();
let streams = system_read.get_streams();
let system = system.write();
let streams = system.get_streams();
for stream in streams {
let topics = stream.get_topics();
for topic in topics {
Expand All @@ -81,11 +81,9 @@ impl ServerCommand<CleanMessagesCommand> for CleanMessagesExecutor {
);

system
.write()
.metrics
.decrement_segments(deleted_segments.segments_count);
system
.write()
.metrics
.decrement_messages(deleted_segments.messages_count);
}
Expand Down

0 comments on commit 9e180ad

Please sign in to comment.