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

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

commit 46a96380b1937c843518b78fbf612d41251c560b
Author: spetz <[email protected]>
AuthorDate: Mon Jul 28 11:37:02 2025 +0200

    fix(sdk): fix possible monotonic time bug in Rust SDK
---
 core/sdk/src/clients/consumer.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/core/sdk/src/clients/consumer.rs b/core/sdk/src/clients/consumer.rs
index 1c5fb728..76a468f0 100644
--- a/core/sdk/src/clients/consumer.rs
+++ b/core/sdk/src/clients/consumer.rs
@@ -770,6 +770,14 @@ impl IggyConsumer {
         }
 
         let now: u64 = IggyTimestamp::now().into();
+        if now < last_sent_at {
+            warn!(
+                "Returned monotonic time went backwards, now < last_sent_at: 
({now} < {last_sent_at})"
+            );
+            sleep(Duration::from_micros(interval)).await;
+            return;
+        }
+
         let elapsed = now - last_sent_at;
         if elapsed >= interval {
             trace!("No need to wait before polling messages. {now} - 
{last_sent_at} = {elapsed}");

Reply via email to