joncrlsn / dque

dque is a fast, embedded, durable queue for Go
MIT License
767 stars 46 forks source link

Make sure the first segment is not empty or it's not complete (is current) #40

Closed nikolaydimitrov closed 1 month ago

nikolaydimitrov commented 1 month ago

In an edge case, on load, we found that it is possible to have the first segment being empty (size()==0) and also complete (reached q.config.ItemsPerSegment limit). In such queue, the Peek() and Deque() return error 'empty', but that is not correct as the queue has another segment with available objects.

joncrlsn commented 1 month ago

Thank you, Nikolay. I merged it. I'm looking for someone who is interested in taking over maintenance of this repository.

On Wed, Oct 23, 2024 at 4:28 AM Nikolay Dimitrov @.***> wrote:

In an edge case, on load, we found that it is possible to have the first segment being empty (size()==0) and also complete (reached q.config.ItemsPerSegment limit). In such queue, the Peek() and Deque() return error 'empty', but that is not correct as the queue has another segment with available objects.

You can view, comment on, or merge this pull request online at:

https://github.com/joncrlsn/dque/pull/40 Commit Summary

File Changes

(2 files https://github.com/joncrlsn/dque/pull/40/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/joncrlsn/dque/pull/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7KRH53OAYEGS3ZCC6OF3Z45T2ZAVCNFSM6AAAAABQOLS3WKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGYYDOOBZHE2TSNY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- When the whole world is running towards a cliff, he who is running in the opposite direction appears to have lost his mind. https://www.azquotes.com/quote/850693

nikolaydimitrov commented 1 month ago

Hi, Jon. Thanks for the quick merge! I actually realised that those segments above need to be also deleted, otherwise they will stay on the filesystem forever. I will create another PR for that. As for the maintenance, I am open to do that as we are using dque in production code and I am comfortable with the code already.