Skip to content

Commit

Permalink
yield on delete so lavinmq doesnt freeze during delete (#859)
Browse files Browse the repository at this point in the history
Yields during MessageStore#delete so that LavinMQ does not freeze while deleting large queues.
  • Loading branch information
viktorerlingsson authored Nov 22, 2024
1 parent 19b2652 commit e47a028
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lavinmq/amqp/queue/message_store.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e47a028

Please sign in to comment.