Skip to content

fix(uptime): clean up some recv() usage and vec allocs#411

Open
klochek wants to merge 2 commits intomainfrom
christopherklochek/vector_fixes
Open

fix(uptime): clean up some recv() usage and vec allocs#411
klochek wants to merge 2 commits intomainfrom
christopherklochek/vector_fixes

Conversation

@klochek
Copy link
Copy Markdown
Contributor

@klochek klochek commented Oct 29, 2025

No description provided.

@klochek klochek requested a review from a team as a code owner October 29, 2025 16:07
@klochek klochek force-pushed the christopherklochek/vector_fixes branch from bc8beda to e87b7c6 Compare November 12, 2025 15:18
@klochek klochek force-pushed the christopherklochek/vector_fixes branch from e87b7c6 to 5a19851 Compare December 2, 2025 19:59
Comment on lines 108 to 114

if !batch.is_empty() {
if let Err(e) = send_batch(
batch,
&mut batch,
client,
config.endpoint,
config.retry_vector_errors_forever,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The pending_items counter is not decremented for items in the final batch, leading to inaccurate metrics after channel closure.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The producer.pending_items counter is incremented for every message but not consistently decremented. Specifically, when the channel closes and recv_many() returns 0, any remaining items in the batch are sent via the final if !batch.is_empty() block (lines 111-118) without a corresponding pending_items.fetch_sub() call. This asymmetry causes the producer.pending_items gauge to retain a non-zero value, equal to the number of items in the final batch, even after all items have been processed and sent, leading to inaccurate monitoring data.

💡 Suggested Fix

Ensure pending_items.fetch_sub(batch.len(), Ordering::Relaxed) is called for the final batch sent at lines 111-118, similar to how full batches are handled.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/producer/vector_producer.rs#L108-L114

Potential issue: The `producer.pending_items` counter is incremented for every message
but not consistently decremented. Specifically, when the channel closes and
`recv_many()` returns 0, any remaining items in the `batch` are sent via the final `if
!batch.is_empty()` block (lines 111-118) without a corresponding
`pending_items.fetch_sub()` call. This asymmetry causes the `producer.pending_items`
gauge to retain a non-zero value, equal to the number of items in the final batch, even
after all items have been processed and sent, leading to inaccurate monitoring data.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 4971860

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.

2 participants