Skip to content

feat(tools/mysql): add show-query-stats and list-all-locks tools for MySQL and Cloud SQL MySQL source#2954

Open
sumeetdhingra-google wants to merge 5 commits intogoogleapis:mainfrom
sumeetdhingra-google:newMySQLTools
Open

feat(tools/mysql): add show-query-stats and list-all-locks tools for MySQL and Cloud SQL MySQL source#2954
sumeetdhingra-google wants to merge 5 commits intogoogleapis:mainfrom
sumeetdhingra-google:newMySQLTools

Conversation

@sumeetdhingra-google
Copy link
Copy Markdown
Contributor

@sumeetdhingra-google sumeetdhingra-google commented Apr 6, 2026

Description

Add the show-query-stats and list-all-locks tools for MySQL. The tools will help in performance monitoring and troubleshooting.

PR Checklist

Thank you for opening a Pull Request! Before submitting your PR, there are a
few things you can do to make sure it goes smoothly:

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #2953

@sumeetdhingra-google sumeetdhingra-google requested a review from a team as a code owner April 6, 2026 09:20
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two new MySQL tools, mysql-list-all-locks and mysql-show-query-stats, along with their corresponding documentation and configuration updates. I have identified several issues: the mysql-list-all-locks tool implementation is missing the extraction of the table_name parameter, the JSON examples in the documentation contain invalid trailing commas, and the test file for mysql-list-all-locks incorrectly references the wrong tool type. Please address these bugs to ensure the new tools function correctly and the documentation is valid.

Comment thread internal/tools/mysql/mysqllistalllocks/mysqllistalllocks.go
Comment thread docs/en/integrations/mysql/tools/mysql-list-all-locks.md Outdated
Comment thread docs/en/integrations/mysql/tools/mysql-show-query-stats.md Outdated
Comment thread internal/tools/mysql/mysqllistalllocks/mysqllistalllocks_test.go Outdated
Comment on lines +137 to +144
table_schema, ok := paramsMap["table_schema"].(string)
if !ok {
return nil, util.NewAgentError("invalid 'table_schema' parameter; expected a string", nil)
}
limit, ok := paramsMap["limit"].(int)
if !ok {
return nil, util.NewAgentError("invalid 'limit' parameter; expected an integer", nil)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with the project's coding standards, use direct type assertions for parameter values instead of ok checks.

	table_schema := paramsMap["table_schema"].(string)
	limit := paramsMap["limit"].(int)
References
  1. Within this project's parameter parsing framework, direct type assertions on parameter values are acceptable without a comma-ok check. The framework's typed constructors (e.g., NewIntParameter) already guarantee type safety, and this is an established pattern for consistency.

@sumeetdhingra-google sumeetdhingra-google requested a review from a team as a code owner April 8, 2026 06:43
Comment thread internal/tools/mysql/mysqllistalllocks/mysqllistalllocks.go
Comment thread tests/tool.go
it.TRX_OPERATION_STATE AS 'current_operation',
substring(it.TRX_QUERY, 1, 100) AS 'query'
FROM
performance_schema.data_locks dl
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is 8.0+ only, right?

sum_no_index_used AS 'full_table_scan_count',
sum_no_good_index_used AS 'inefficient_index_used_count',
last_seen AS 'last_executed'
FROM performance_schema.events_statements_summary_by_digest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a concern that the instance does not have p_s enabled?

Comment thread tests/tool.go
}

// Generating stats for query
selectStmt := fmt.Sprintf("SELECT * FROM %s WHERE id = 1 FOR UPDATE", testTableName)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is the query going to be "long" enough to facilitate the tests?

@Yuan325 Yuan325 added the release candidate Use label to signal PR should be included in the next release. label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release candidate Use label to signal PR should be included in the next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New MySQL tools for query stats and listing all locks

3 participants