There are race conditions in the Enqueue method of the ConcurrentCircularBuffer.
The buffer limit is (implemented as a check and "wrap") is two separate Interlocked operations (rather than a single interlocked operation). This could (and does) result in the value of the _head field exceeding _maxSize - 1
if (Interlocked.Increment(ref _head) > (_maxSize - 1))
Interlocked.Exchange(ref _head, 0);
This can result in a out of bounds exception when assigning the parameter object to the values array.
There are race conditions in the Enqueue method of the ConcurrentCircularBuffer.
The buffer limit is (implemented as a check and "wrap") is two separate Interlocked operations (rather than a single interlocked operation). This could (and does) result in the value of the _head field exceeding _maxSize - 1
This can result in a out of bounds exception when assigning the parameter object to the values array.
I've attached a pull request with a re-implementation of the ConcurrentCircularBuffer without these issues (https://github.com/Jroland/kafka-net/pull/71).