Skip to content

Commit

Permalink
Delete only expired segments which are closed (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
spetz authored Apr 16, 2024
1 parent ae5c9c8 commit 59999f1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "server"
version = "0.2.20"
version = "0.2.21"
edition = "2021"
build = "src/build.rs"

Expand Down
2 changes: 1 addition & 1 deletion server/src/streaming/partitions/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Partition {
pub async fn get_expired_segments_start_offsets(&self, now: u64) -> Vec<u64> {
let mut expired_segments = Vec::new();
for segment in &self.segments {
if segment.is_expired(now).await {
if segment.is_closed && segment.is_expired(now).await {
expired_segments.push(segment.start_offset);
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/streaming/segments/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl Segment {
return false;
}

let last_messages = self.get_messages(self.end_offset, 1).await;
let last_messages = self.get_messages(self.current_offset, 1).await;
if last_messages.is_err() {
return false;
}
Expand Down

0 comments on commit 59999f1

Please sign in to comment.