Skip to content

Conversation

sialais
Copy link

@sialais sialais commented Oct 9, 2025

Summary

Fix issue #23872

How did you test this PR?

Because the issue is hard to reproduce, (I can only reproduce it in my production environment, with huge data), I put my build on my production environment, and the issue fixed.

This bug will make the self monitoring metrics incorrect: when buffer counter undeflowed, metrics will be reset.
metrics

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

@sialais sialais requested a review from a team as a code owner October 9, 2025 09:04
@pront pront requested a review from bruceg October 9, 2025 14:57
@pront
Copy link
Member

pront commented Oct 9, 2025

Hi @sialais, thank you for the PR! Please add a changelog explaining the change.

@sialais sialais force-pushed the bugfix/fix_buffer_counter_underflowed branch from fcc55dd to b222f23 Compare October 10, 2025 00:44
@sialais
Copy link
Author

sialais commented Oct 10, 2025

Hi @sialais, thank you for the PR! Please add a changelog explaining the change.

@pront, sorry for missing that. I've added a changlog.

@pront pront self-assigned this Oct 10, 2025
Copy link
Member

@bruceg bruceg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution, @sialais. It would be great to nail down this buffer counter underflow issue, as I have seen it to. That said, I am a little uncertain about some of the details in this change.

true,
);
}
was_dropped = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to your change, but should this be setting sent_to_base = false; as well here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessory to keep two flags send_to_base, was_dropped. The event will either sent_to_base or dropped.
I've updated my commit, and sent_to_base is removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sialais, thank you for your work on this. It would be best if you don't force push to this branch to make incremental reviews easier. Thanks!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sialais, thank you for your work on this. It would be best if you don't force push to this branch to make incremental reviews easier. Thanks!

Gotted!

}
}
WhenFull::Overflow => {
if let Some(item) = self.base.try_send(item).await? {
Copy link
Member

@bruceg bruceg Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally familiar with the implementation here, so pardon if this is a naive question. The other two sends call increment_received_event_count_and_byte_size before sending, this one never calls it. Is that an omission?

This comment was marked as outdated.

Copy link
Author

@sialais sialais Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that, My previous commit did indeed contain an error. I've never used Overflow before, and after my build is tested, I've forgot the last case of WhenFull::Overflow, apologize.
Because resolving this issue requires updating the counter before sending the event to the buffer, when handling the Overflow branch—if the overflow logic is triggered and the message is sent to overflow buffer—the counter needs to be decremented. However, neither using send nor drop to perform this countdown is quite appropriate. Therefore, to address the problem I was facing, I chose to ignore this particular scenario for temporarily.
Now that I think about it again, maybe using drop to update the counter is actually reasonable—since the event is effectively "dropped" into the overflow buffer?
I've updated my commit, but not tested.

@sialais sialais force-pushed the bugfix/fix_buffer_counter_underflowed branch from b222f23 to 34da1d1 Compare October 16, 2025 10:10
@sialais sialais force-pushed the bugfix/fix_buffer_counter_underflowed branch from 34da1d1 to dedcf6a Compare October 16, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buffer counter underflowed warnings

3 participants