From e1cc7fb0b402baee94dceeeb7a1d21951925c118 Mon Sep 17 00:00:00 2001 From: Marco Chan Date: Fri, 16 Aug 2024 09:29:17 +0100 Subject: [PATCH] Retrieve end offsets before searching for offsets for timestamp - this fixes a race condition where a message could be produced after offsets for timestamp but before end offsets are retrieved. --- src/jackdaw/client.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jackdaw/client.clj b/src/jackdaw/client.clj index 3692677d..6509de85 100644 --- a/src/jackdaw/client.clj +++ b/src/jackdaw/client.clj @@ -281,10 +281,10 @@ [^Consumer consumer timestamp topics] (let [topic-partitions (->> (mapcat #(partitions-for consumer %) topics) (map #(select-keys % [:topic-name :partition]))) + end-offsets (end-offsets consumer topic-partitions) ts-offsets (offsets-for-times consumer (zipmap topic-partitions (repeat (count topic-partitions) timestamp))) - end-offsets (end-offsets consumer topic-partitions) offsets (reduce-kv (fn [m k v] (assoc m k {:ts-offset v :end-offset (get end-offsets k)}))