While flushing, the data channel is switched if a new allocated one which can cause the loss of messages because the length can be zero which would stop the procedure and at the same time a new message can be sent to the channel.
Modifications
Instead of allocating a new channel, it empties the existing one up to the length of the buffer of the channel before proceeding with the flush.
Verifying this change
[x] Make sure that the change passes the CI checks.
This change is already covered by existing tests, such as TestFlushInProducer.
Documentation
Does this pull request introduce a new feature? no
Fixes #1258
Motivation
While flushing, the data channel is switched if a new allocated one which can cause the loss of messages because the length can be zero which would stop the procedure and at the same time a new message can be sent to the channel.
Modifications
Instead of allocating a new channel, it empties the existing one up to the length of the buffer of the channel before proceeding with the flush.
Verifying this change
This change is already covered by existing tests, such as TestFlushInProducer.
Documentation