Skip to content
This repository was archived by the owner on Sep 21, 2024. It is now read-only.

Bug in ElasticCircularBuffer #113

@zllai

Description

@zllai

Hi Ambrosia team,

I am recently studying the Ambrosia source code. I think I may find a bug in ElasticCircularBuffer implemented in Ambrosia/Ambrosia/CircularBuffers.cs, though it seems not causing any trouble for now.

IEnumerable<T> Iterate()
{
    foreach (CircularBuffer<T> buffer in buffers)
    {
        foreach (T item in buffer.Iterate())
        {
             yield return item;
        }
    }
}

The first foreach iterates from buffers.First to buffers.Last. But this is actually not the desired behavior. Because when enqueued, the ElasticCircularBuffer reuses buffers.First if buffers.First contains an empty CircularBuffer, making buffers.First not actually the head. I also didn't see buffers.First being updated anywhere.

I guess it didn't cause any trouble because in testcases, CircularBuffer is big enough to hold all pending messages, so that ElasticCircularBuffer always contains only one CircularBuffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions