Skip to content

Conversation

@renecannao
Copy link
Contributor

Summary

This pull request adds comprehensive documentation for several ProxySQL features and includes a bug fix:

  1. Query rules capture groups and backreferences (6966b79d)

    • Documentation for using regex capture groups and backreferences in ProxySQL query rules
    • Includes practical examples, best practices, and testing methods
  2. "Closing killed client connection" warnings (de214cb5)

    • Detailed documentation explaining the two-phase kill process
    • Troubleshooting guide for diagnosing connection termination causes
    • Configuration reference and best practices
  3. Doxygen documentation for vacuum_stats() and stats_pgsql_stat_activity (efe0d4fe)

    • Includes bug fix: Comments out stats_pgsql_stat_activity from the deletion list in vacuum_stats() because it's a SQL VIEW, not a table
    • Documents why attempting DELETE on the view would cause SQLite error: "cannot modify stats_pgsql_stat_activity because it is a view"
    • Explains the relationship between the view and its underlying table stats_pgsql_processlist
  4. coredump_filters feature documentation (cf8cbfd8) - Addresses issue Document coredump_filters feature and LOAD/SAVE COREDUMP commands #5213

    • Documents the on-demand core dump generation feature
    • Covers table definitions, admin commands (LOAD COREDUMP TO RUNTIME), configuration variables, usage examples, and platform support
    • Includes important notes about case-sensitive filenames, runtime-only behavior, and rate limiting

Bug Fix Details

Commit efe0d4fe fixes a bug where vacuum_stats() would attempt to delete rows from stats_pgsql_stat_activity, which is a SQL VIEW. This would cause the SQLite error:

"cannot modify stats_pgsql_stat_activity because it is a view"

The view is now properly excluded from the deletion list (commented out), while the documentation explains that clearing the underlying stats_pgsql_processlist table automatically clears the view's content.

…stat_activity

This commit documents:
1. The vacuum_stats() function's purpose, behavior, and the reason why
   stats_pgsql_stat_activity is excluded from bulk deletion operations
2. The fact that stats_pgsql_stat_activity is a SQL VIEW (not a table)
   and attempting DELETE on it would cause SQLite error:
   "cannot modify stats_pgsql_stat_activity because it is a view"

The documentation explains:
- Why TRUNCATE stats_mysql_query_digest triggers vacuum_stats(true)
- Why both MySQL and PostgreSQL tables are cleared regardless of protocol
- How the view is automatically cleared via its underlying table
  stats_pgsql_processlist
- The importance of keeping the view excluded from deletion lists
Add comprehensive documentation for the on‑demand core dump generation
feature introduced in PR #4225. The documentation covers:

- coredump_filters and runtime_coredump_filters table definitions
- LOAD COREDUMP TO RUNTIME admin command and its aliases
- Configuration variables admin‑coredump_generation_threshold and
  admin‑coredump_generation_interval_ms
- Usage examples with INSERT and LOAD commands
- Important notes about case‑sensitive filenames, runtime‑only behavior,
  rate limiting, and platform support
- Troubleshooting guidance and best practices

The documentation addresses the missing documentation reported in
GitHub issue #5213.
@gemini-code-assist
Copy link

Summary of Changes

Hello @renecannao, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances ProxySQL's documentation by adding comprehensive guides for several key features, including the use of regex capture groups in query rules, the two-phase process behind 'killed client connection' warnings, and the on-demand core dump generation (coredump_filters). Additionally, it includes a critical bug fix in the vacuum_stats() function to prevent errors when attempting to delete from the stats_pgsql_stat_activity SQL view.

Highlights

  • Query Rules Documentation: Added comprehensive documentation for using regex capture groups and backreferences within ProxySQL query rules, including practical examples and best practices.
  • Client Connection Warnings Documentation: Provided detailed documentation explaining the two-phase kill process for client connections, troubleshooting guides for 'Closing killed client connection' warnings, and relevant configuration parameters.
  • Vacuum Stats Bug Fix and Documentation: Fixed a bug in vacuum_stats() where it attempted to delete from the stats_pgsql_stat_activity SQL VIEW, causing SQLite errors. The view is now correctly excluded, and Doxygen documentation has been added to clarify this behavior.
  • Coredump Filters Documentation: Introduced documentation for the coredump_filters feature, which allows on-demand core dump generation. This covers table definitions, admin commands, usage examples, rate limiting, and platform support.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@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 is a great addition, providing extensive documentation for several features and fixing a bug in vacuum_stats(). The new documentation for query rules, killed connections, and coredump filters is comprehensive and will be very helpful for users. The bug fix correctly prevents DELETE operations on a SQL VIEW, and the associated code comments are clear and informative. I've identified a few issues, primarily in the new documentation files, related to the use of non-standard characters (non-breaking hyphens) which could cause issues for users copying and pasting commands. I've also found an incomplete code example. Addressing these will improve the quality and usability of the documentation.

Comment on lines +58 to +59
| `admin‑coredump_generation_threshold` | 10 | 1–500 | Maximum number of core files that can be generated during the lifetime of the ProxySQL process. |
| `admin‑coredump_generation_interval_ms` | 30000 (30 seconds) | 0–INT_MAX | Minimum time between two consecutive core dump generations. A value of `0` disables the interval check. |

Choose a reason for hiding this comment

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

high

The variable names like admin‑coredump_generation_threshold use a non-breaking hyphen (U+2011) instead of a standard hyphen-minus (U+002D). This can cause copy-paste errors for users trying to run commands. Please replace all non-breaking hyphens in variable names and code blocks with standard hyphens. For example, admin‑coredump_generation_threshold should be admin-coredump_generation_threshold. This issue appears in multiple places in this file (e.g., lines 58, 59, 108, 168, 170, 181, 237, 244) and other documentation files in this PR.

**Investigation Steps**:
1. **Enable audit logging**:
```sql
SET mysql-auditlog_filename='/var/log/proxysql_audit.log';

Choose a reason for hiding this comment

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

high

The example for enabling audit logging is incomplete. It's missing SET mysql-auditlog=true;. Without this, setting the filename will not enable logging. I suggest adding it for the example to be functional, similar to the more complete example in the 'Best Practices' section (lines 154-159).

Suggested change
SET mysql-auditlog_filename='/var/log/proxysql_audit.log';
SET mysql-auditlog_filename='/var/log/proxysql_audit.log';
SET mysql-auditlog=true;

Comment on lines +131 to +135
| `mysql‑wait_timeout` | 28800000 ms (8 hours) | Maximum idle time before connection is killed. |
| `mysql‑max_transaction_idle_time` | 0 (disabled) | Maximum idle time for an open transaction. |
| `mysql‑max_transaction_time` | 0 (disabled) | Maximum total time a transaction can run. |
| `mysql‑session_fast_forward` | false | Enable fast‑forward mode (kills connections if backends go OFFLINE). |
| `mysql‑throttle_max_transaction_time` | 0 (disabled) | Alternative to `max_transaction_time`; throttles instead of kills. |

Choose a reason for hiding this comment

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

high

The variable names in this table use a non-breaking hyphen (U+2011) instead of a standard hyphen-minus (U+002D). This can cause copy-paste errors for users. Please replace all non-breaking hyphens in variable names (e.g., mysql‑wait_timeout) and code blocks with standard hyphens (mysql-wait_timeout). This issue appears in multiple places in this file (e.g., lines 34, 41, 47, 53, 131-135, 182, 195).


Suppose you want to generate a core dump when the function `MySQL_Data_Stream::check_data_flow()` reaches line 485 (where `generate_coredump()` is called).

First, find the exact file name as used in the source code. The macro `LOCATION()` expands to `__FILE__ ":" __LINE__`. For the file `lib/mysql_data_stream.cpp` line 485:

Choose a reason for hiding this comment

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

medium

The explanation of the LOCATION() macro is slightly misleading. The expression __FILE__ ":" __LINE__ is not valid C preprocessor syntax for concatenating a string and an integer macro. The actual implementation uses stringification macros. To avoid confusion, I suggest rephrasing this to focus on the result rather than the implementation detail.

Suggested change
First, find the exact file name as used in the source code. The macro `LOCATION()` expands to `__FILE__ ":" __LINE__`. For the file `lib/mysql_data_stream.cpp` line 485:
First, find the exact file name as used in the source code. The internal macro `LOCATION()` creates a string literal by combining the filename and line number (e.g., `"lib/mysql_data_stream.cpp:485"`). For the file `lib/mysql_data_stream.cpp` line 485:


1. **Use for debugging only**: Enable coredump filters only during debugging sessions. Remove filters afterward to avoid unnecessary overhead.
2. **Limit the threshold**: Keep `admin‑coredump_generation_threshold` low (e.g., 1‑5) unless you are investigating a recurring issue.
3. **Set a reasonable interval**: A minimum interval of several seconds (e.g., 30000 ms) prevents storm generation.

Choose a reason for hiding this comment

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

medium

The text 30000 ms uses a narrow no-break space (U+202F) instead of a regular space. This can be invisible to users and might cause issues. It's better to use a standard space for consistency and to avoid potential copy-paste or rendering problems.

Suggested change
3. **Set a reasonable interval**: A minimum interval of several seconds (e.g., 30000ms) prevents storm generation.
3. **Set a reasonable interval**: A minimum interval of several seconds (e.g., 30000 ms) prevents storm generation.

@sonarqubecloud
Copy link

@renecannao renecannao merged commit 88edaac into v3.0 Dec 19, 2025
5 of 6 checks passed
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