Skip to content

Conversation

@kongfei605
Copy link
Collaborator

No description provided.

Copy link
Contributor

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 adds a database connectivity check using Ping() to the PostgreSQL input plugin. When the Ping fails, the plugin sets the up metric to 0 and returns early, preventing attempts to query a non-responsive database.

Key Changes:

  • Added Ping() check after opening database connection to verify connectivity before proceeding with queries
  • Sets up=0 metric when Ping fails to indicate database is unreachable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 2, 2025 08:26
Copy link
Contributor

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 163 to 167
if err := ins.db.Ping(); err != nil {
slist.PushSample(inputName, "up", 0, tags)
log.Println("E! failed to ping postgresql:", err)
return
}
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The Ping check should be performed after setting the connection pool parameters (SetMaxOpenConns, SetMaxIdleConns, SetConnMaxLifetime).

The MySQL input plugin (lines 213-221 in inputs/mysql/mysql.go) follows this pattern:

  1. Opens database connection
  2. Sets connection pool parameters
  3. Performs Ping check
  4. Sets up=1

This is the recommended order because the connection pool settings should be configured before attempting to use the connection. Consider moving this Ping check to after line 172 (after SetConnMaxLifetime).

Copilot uses AI. Check for mistakes.
@kongfei605 kongfei605 merged commit 302d80c into flashcatcloud:main Dec 2, 2025
3 checks passed
@kongfei605 kongfei605 deleted the postgresql branch December 2, 2025 08:42
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