This is an automated email from the ASF dual-hosted git repository.

piotr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iggy.git


The following commit(s) were added to refs/heads/master by this push:
     new c84d3166 fix(server): fix getting first messages when segment was 
removed (#1828)
c84d3166 is described below

commit c84d316651fbd875cf2302064e5940fc90d30c5d
Author: Hubert Gruszecki <[email protected]>
AuthorDate: Thu May 29 22:56:09 2025 +0200

    fix(server): fix getting first messages when segment was removed (#1828)
---
 core/server/src/streaming/partitions/messages.rs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/server/src/streaming/partitions/messages.rs 
b/core/server/src/streaming/partitions/messages.rs
index 97a2771e..25c78247 100644
--- a/core/server/src/streaming/partitions/messages.rs
+++ b/core/server/src/streaming/partitions/messages.rs
@@ -84,7 +84,12 @@ impl Partition {
 
     // Retrieves the first messages (up to a specified count).
     pub async fn get_first_messages(&self, count: u32) -> 
Result<IggyMessagesBatchSet, IggyError> {
-        self.get_messages_by_offset(0, count).await
+        if self.segments.is_empty() {
+            return Ok(IggyMessagesBatchSet::empty());
+        }
+        let oldest_available_offset = self.segments[0].start_offset();
+        self.get_messages_by_offset(oldest_available_offset, count)
+            .await
     }
 
     // Retrieves the last messages (up to a specified count).

Reply via email to