Skip to content

[Issue 1258][producer] Avoid a data race when flushing with load - #1261

Merged
RobertIndie merged 1 commit into
apache:masterfrom
Gilthoniel:bugfix/data-chan-race
Jul 30, 2024
Merged

RobertIndie merged 1 commit into
apache:masterfrom
Gilthoniel:bugfix/data-chan-race

Conversation

@Gilthoniel

@Gilthoniel Gilthoniel commented Jul 26, 2024 •

Copy link
Copy Markdown
Contributor

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

  • 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

@nodece nodece added this to the v0.14.0 milestone Jul 29, 2024
@RobertIndie
RobertIndie merged commit 8dd4ed1 into apache:master Jul 30, 2024
RobertIndie pushed a commit that referenced this pull request Jul 31, 2024
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.

(cherry picked from commit 8dd4ed1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible data race in internalFlush

3 participants