From 11ff08acd58c647d0fdf7c13c2f0f7aee50394b6 Mon Sep 17 00:00:00 2001 From: Ryan Sundberg Date: Wed, 25 Apr 2018 13:18:10 -0700 Subject: [PATCH] Drop slab data on initialization that does not fit when slab size > max-queue-size --- src/durable_queue.clj | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/durable_queue.clj b/src/durable_queue.clj index d468a38..0b86953 100644 --- a/src/durable_queue.clj +++ b/src/durable_queue.clj @@ -590,12 +590,13 @@ (swap! empty-slabs conj slab)) (do - (doseq [task tasks] - (status! task :incomplete) - (when-not (.offer q' task) - (throw - (IllegalArgumentException. - "'max-queue-size' insufficient to hold existing tasks.")))) + (loop [tasks tasks] + (when-let [task (first tasks)] + (status! task :incomplete) + ; Continue loading until data doesn't fit into the queue. + ; Drop data in slabs that overflows queue size. + (when (.offer q' task) + (recur (rest tasks))))) (unmap slab))))) (let [^AtomicLong counter (get-in @queue-name->stats [q :enqueued])]