From faf858429bf343d2b6e35095d3cb8bfcbe744e50 Mon Sep 17 00:00:00 2001 From: Viktor Erlingsson Date: Fri, 22 Nov 2024 15:08:58 +0100 Subject: [PATCH] yield on delete so lavinmq doesnt freeze during delete --- src/lavinmq/amqp/queue/message_store.cr | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lavinmq/amqp/queue/message_store.cr b/src/lavinmq/amqp/queue/message_store.cr index 41fc1fa1b..62c0d28ca 100644 --- a/src/lavinmq/amqp/queue/message_store.cr +++ b/src/lavinmq/amqp/queue/message_store.cr @@ -195,11 +195,17 @@ module LavinMQ def delete close - @segments.each_value { |f| @replicator.try &.delete_file(f.path); f.delete } - @acks.each_value { |f| @replicator.try &.delete_file(f.path); f.delete } + @segments.each_value { |f| delete_file(f) } + @acks.each_value { |f| delete_file(f) } FileUtils.rm_rf @queue_data_dir end + def delete_file(file) + @replicator.try &.delete_file(file.path) + file.delete(raise_on_missing: false) + Fiber.yield + end + def empty? @size.zero? end