Skip to content

Conversation

kongfei605
Copy link
Collaborator

No description provided.

@kongfei605 kongfei605 requested a review from Copilot July 24, 2025 01:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a panic in the ClickHouse input module by preventing index out of bounds errors when executing custom queries. The fix ensures safe connection distribution when the number of custom metrics exceeds the number of available connections.

  • Adds a safety check to return early when no connections are available
  • Implements modulo-based connection distribution to prevent array index overflow
  • Updates log level from error to informational for metrics count logging

@@ -187,15 +187,21 @@ func (ins *Instance) Gather(slist *types.SampleList) {
log.Println("E! failed to exec query commonMetrics error:", err)
}
}
log.Println("E!metrics=", len(ins.Metrics))
log.Println("I!metrics=", len(ins.Metrics))
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using structured logging instead of concatenating strings in log messages. For example: log.Printf("I! metrics count: %d", len(ins.Metrics))

Suggested change
log.Println("I!metrics=", len(ins.Metrics))
log.Printf("I! metrics count: %d", len(ins.Metrics))

Copilot uses AI. Check for mistakes.

@kongfei605 kongfei605 merged commit 44e4212 into flashcatcloud:main Jul 24, 2025
3 checks passed
@kongfei605 kongfei605 deleted the clickhouse_fix branch July 24, 2025 01:36
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.

1 participant