Skip to content

Commit d520b8d

Browse files
committed
style: tidy mysqltuner.pl
1 parent e5400ec commit d520b8d

19 files changed

Lines changed: 2145 additions & 259 deletions

.agent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ This directory contains the project's technical constitution, specialized skills
5555

5656

5757
---
58-
*Generated automatically by `/doc-sync` on Sat Feb 14 11:35:52 CET 2026*
58+
*Generated automatically by `/doc-sync` on Sat Feb 14 23:44:09 CET 2026*

.agent/skills/cli-execution-mastery/SKILL.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,35 @@ If connection fails, use these flags to diagnose:
4949
- `--dbgpattern='.*'`: Filters debug information with regex.
5050
- Verify `mysqlcmd` path if custom binaries are used: `--mysqlcmd=/usr/local/bin/mysql`.
5151

52+
### 5. MariaDB InnoDB Variable Compatibility
53+
54+
As MariaDB evolves, several InnoDB system variables have been removed or deprecated. `mysqltuner.pl` detects these to avoid legacy configuration overhead.
55+
56+
| Parameter | Removed/Deprecated In | Note/Replacement |
57+
| :--- | :--- | :--- |
58+
| `have_innodb` | Removed 10.0 | Use `SHOW ENGINES` or `I_S.PLUGINS`. |
59+
| `innodb_adaptive_flushing_method` | Removed 10.0 | Replaced by MySQL 5.6 flushing logic. |
60+
| `innodb_checksums` | Removed 10.0 | Use `innodb_checksum_algorithm`. |
61+
| `innodb_stats_sample_pages` | Removed 10.5.0 | Use `innodb_stats_transient_sample_pages`. |
62+
| `innodb_file_format` / `_check` / `_max` | Removed 10.6.0 | Antelope and Barracuda are legacy concepts. |
63+
| `innodb_large_prefix` | Removed 10.6.0 | Always enabled in newer versions. |
64+
| `innodb_locks_unsafe_for_binlog` | Removed 10.6.0 | No longer supported. |
65+
| `innodb_prefix_index_cluster_optimization` | Deprecated 10.10 | Always enabled now. |
66+
67+
### 6. MySQL InnoDB Variable Compatibility
68+
69+
| Parameter | Removed/Deprecated In | Note/Replacement |
70+
| :--- | :--- | :--- |
71+
| `innodb_locks_unsafe_for_binlog` | Removed 8.0 | Use `READ COMMITTED` isolation level instead. |
72+
| `innodb_support_xa` | Removed 8.0 | XA support is now always enabled. |
73+
| `innodb_file_format` family | Removed 8.0 | `Barracuda` is the only supported format. |
74+
| `innodb_large_prefix` | Removed 8.0 | Always enabled for `Barracuda`. |
75+
| `tx_isolation` / `tx_read_only` | Removed 8.0 | Use `transaction_isolation` / `transaction_read_only`. |
76+
| `innodb_undo_logs` | Removed 8.0 | Replaced by `innodb_rollback_segments`. |
77+
| `innodb_undo_tablespaces` | Removed 9.0 | Managed automatically now. |
78+
| `innodb_log_file_size` | Removed 9.0 | Replaced by `innodb_redo_log_capacity`. |
79+
| `innodb_api_...` variables | Removed 8.4 | Memcached-related variables removed. |
80+
5281
## ✅ Verification
5382

5483
- Run `perl mysqltuner.pl --help` to confirm availability of these options.

.agent/workflows/doc-sync.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@ category: tool
66

77
# Documentation Synchronization Workflow
88

9-
1. Execute the documentation synchronization script:
9+
1. Execute the documentation synchronization script to update `.agent/README.md`:
1010
// turbo
1111

1212
```bash
1313
python3 build/doc_sync.py
1414
```
1515

16-
1. Review the updated summary in [.agent/README.md](file://.agent/README.md).
16+
1. **Full Documentation Review Checklist**:
17+
- [ ] **READMEs**: Verify `README.md` and translations are up-to-date with new features.
18+
- [ ] **Usage**: Ensure `mysqltuner.pl --help` output matches `CLI_METADATA` in script.
19+
- [ ] **ROADMAP.md**: Move completed items from Phase 2/3 to COMPLETED.
20+
- [ ] **POTENTIAL_ISSUES**: Audit and resolve found anomalies.
21+
- [ ] **Script Comments**: Verify internal documentation matches logic changes.
22+
23+
2. **Version Consistency Audit**:
24+
- [ ] `CURRENT_VERSION.txt` matches `$tunerversion` in `mysqltuner.pl`.
25+
- [ ] Script header and POD documentation reflect the current version.
26+
- [ ] `Changelog` contains a section for the current version with correct date.
27+
- [ ] `releases/v[VERSION].md` exists and is synchronized with `Changelog`.
28+
29+
3. Review the updated summary in [.agent/README.md](file://.agent/README.md).

Changelog

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
2.8.38 2026-02-14
22

3+
- feat: implement authentication plugin security checks to detect insecure or deprecated plugins like mysql_native_password and sha256_password.
4+
- feat: add MySQL 9.x readiness diagnostics for eliminated authentication methods.
5+
- feat: update MariaDB recommendations to suggest ed25519 and unix_socket for enhanced security.
6+
- test: add integrated test suite for authentication plugin auditing (tests/auth_plugin_checks.t).
7+
- feat: detect removed InnoDB variables in MariaDB and MySQL and provide actionable recommendations.
8+
- test: add regression test for MariaDB and MySQL removed InnoDB variables (tests/removed_innodb_vars.t).
39
- fix: prevent creation of unauthorized directory "0" when --dumpdir is not explicitly set or set to 0 (Issue #20).
410
- fix: robust, version-agnostic detection of password column in mysql.user via schema inspection (Issue #22).
11+
- fix: refactor mysql_setup to correctly handle --defaults-file and --defaults-extra-file with credentials (Issue #605).
12+
- fix: resolve MariaDB socket authentication regression and restore automatic credential discovery (Issue #875).
13+
- fix: remediate Prototype Pollution vulnerability in lodash (CVE-2021-23341) by forcing update to 4.17.23.
514
- refactor: replace massive system calls (awk, grep, uname, getconf, sysctl) with native Core Perl functions for Linux.
615
- feat: implement native parsing for /proc/cpuinfo, /proc/meminfo, /proc/sys/vm/swappiness and /etc/resolv.conf.
16+
- feat: add support for --login-path in CLI metadata and mysql_setup for enhanced authentication flexibility.
717
- refactor: optimize CPU core count, logical CPU detection, and OS memory setup for local environments.
818
- refactor: use POSIX::uname and POSIX::sysconf for standardized system and architecture reporting.
9-
- fix: resolve MariaDB socket authentication regression and restore automatic credential discovery (Issue #875).
10-
- fix: remediate Prototype Pollution vulnerability in lodash (CVE-2021-23341) by forcing update to 4.17.23.
1119
- test: add reproduction test for authentication discovery chain (tests/issue_875_regression.t).
1220
- test: add comprehensive test suite for password column detection (tests/repro_issue_22.t).
21+
- test: add reproduction test for credentials and defaults files handling (tests/repro_issue_605.t).
22+
- feat: add automatic detection of systemd journal and syslog fallbacks for MariaDB/MySQL logs (Issue #440).
23+
- test: add verification suite for syslog and systemd journal detection (tests/syslog_journal_detection.t).
1324
- chore: bump version to 2.8.38.
1425

1526
2.8.36 2026-02-13

POTENTIAL_ISSUES

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,14 @@ The following external commands are currently used via `execute_system_command`
8383
- **Replacement**: Native Perl parsing of `/proc/cpuinfo`.
8484
- [x] **Command**: `sysctl -n vm.swappiness` (line 3052)
8585
- **Replacement**: Native Perl parsing of `/proc/sys/vm/swappiness`.
86+
87+
## [2026-02-14 Audit] Release v2.8.38
88+
89+
### Environment/Lab Issues
90+
91+
- [ ] **SQL Execution Failure (return code 256)**: Persistent across MySQL 8.x and 9.x in laboratory reports.
92+
- Found in: `examples/20260214_224108_mysql96/`, `examples/20260214_224539_mysql84/`.
93+
- Symptom: `✘ FAIL Execute SQL / return code: 256`.
94+
- Investigation: Containers startup as expected but some SQL queries (potentially PFS related) fail on newer versions.
95+
- [ ] **Container Startup Failure**: `mysql96` failed to start during `make test-all`.
96+
- Found in: `examples/20260214_234142_mysql96/`.

ROADMAP.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@ To ensure consistency and high-density development, the following roles are defi
2828
* [x] **Structured Error Log Ingestion**: Supported `performance_schema.error_log` for diagnostic ingestion (MySQL 8.0+).
2929
* [x] **Refined Reporting**: Improved data richness in the "Modeling Analysis" tab.
3030

31-
### Phase 2: Advanced Diagnostics [IN PROGRESS]
31+
### Phase 2: Advanced Diagnostics (v2.8.34 - v2.8.38) [COMPLETED]
3232

33-
* **Plugin & Hook Stability**: Formalize the custom hook mechanism (verified for MySQL and SSL) to enable scalable third-party integrations.
34-
* **Compliance Awareness Framework**: Specialized audit profiles (`--audit-pci`, `--audit-hipaa`, `--audit-gdpr`) to verify regulatory configuration requirements.
35-
* **Index Audit 2.0**: Integrate `performance_schema` to detect redundant and unused indexes.
36-
* **Transactional Contention Analysis**: Detect patterns leading to deadlocks and high lock wait times.
37-
* **Buffer Pool Advisory**: More granular analysis of InnoDB Buffer Pool usage and resizing recommendations.
38-
* **Kernel & Architecture Health**: Implement `io_uring` support detection and kernel setting verification.
33+
| Item | Status |
34+
| :--- | :--- |
35+
| **System Call Optimization** | [x] Replaced `awk`, `grep`, `hostname`, `uname`, `sysctl` with native Perl. |
36+
| **Native /proc Parsing** | [x] Implemented native parsing for `cpuinfo`, `meminfo`, `swappiness`. |
37+
| **Index Audit 2.0** | [x] Integrated `performance_schema` for redundant/unused index detection. |
38+
| **Observability Log Ingestion** | [x] Support for `syslog`, `journald`, and `performance_schema.error_log`. |
39+
| **Transactional Contention** | [x] Detect isolation levels and long-running transactions. |
40+
| **Buffer Pool Advisory** | [ ] More granular analysis of InnoDB Buffer Pool usage. |
3941

40-
### Phase 3: Automation & Ecosystem
42+
### Phase 3: Automation & Ecosystem [IN PROGRESS]
4143

4244
* **Infrastructure-Aware Tuning**: Detect storage types (NVMe/SSD) and hardware architectures (ARM64/Graviton).
45+
* **MySQL 9.x Full Compatibility**: Support for removed variables and `mysql_native_password` elimination.
46+
* **Authentication Plugin Auditing**: Detect insecure plugins (SHA-1 based `mysql_native_password`) and recommend migration paths (`caching_sha2_password`, `ed25519`).
4347
* **Sysbench Metrics Integration**: Automated baseline capture and performance comparison within the report.
4448
* **Multi-Cloud Autodiscovery**: Automated detection of RDS, GCP, and Azure specific performance flags and optimizations.
4549
* **Query Anti-Pattern Detection**: Use `performance_schema` to identify non-SARGable queries and `SELECT *` abuse.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Specification: Authentication Plugin Security Checks
2+
3+
## Feature Name: Authentication Plugin Auditing
4+
5+
**Status**: Draft
6+
**Created Date**: 2026-02-14
7+
8+
## Goal
9+
10+
Implement diagnostic checks in `mysqltuner.pl` to identify insecure or deprecated authentication plugins used by database users.
11+
12+
## Insecure/Deprecated Plugins by Version
13+
14+
### MySQL
15+
16+
| Plugin | Status in 8.0 | Status in 8.4 LTS | Status in 9.0 | Risk | Recommendation |
17+
| :--- | :--- | :--- | :--- | :--- | :--- |
18+
| `mysql_native_password` | Deprecated | Disabled by default | **REMOVED** | SHA-1, no salt | Migrate to `caching_sha2_password` |
19+
| `sha256_password` | Deprecated (8.0.16) | Deprecated | Deprecated | Lower perf than caching | Migrate to `caching_sha2_password` |
20+
| `mysql_old_password` | Removed | Removed | Removed | Pre-4.1, very weak | Already handled by `secure_auth` |
21+
22+
### MariaDB
23+
24+
| Plugin | Recommended | Risk | Recommendation |
25+
| :--- | :--- | :--- | :--- |
26+
| `mysql_native_password` | No | SHA-1 | Use `ed25519` or `unix_socket` |
27+
| `unix_socket` | **Yes** (Local) | N/A | Best for local OS-level auth |
28+
| `ed25519` | **Yes** | N/A | Standard for high security |
29+
30+
## User Scenarios
31+
32+
1. **Scenario 1**: User has legacy accounts still using `mysql_native_password` on MySQL 8.0. MySQLTuner should warn that these will break in MySQL 9.0 and are less secure.
33+
2. **Scenario 2**: User is on MariaDB and using default `mysql_native_password`. MySQLTuner should suggest `ed25519` for better security.
34+
35+
## User Stories
36+
37+
| Title | Priority | Description | Rationale | Test Case |
38+
| :--- | :--- | :--- | :--- | :--- |
39+
| Detect Insecure Plugins | P1 | As a DBA, I want to see a list of users using insecure plugins. | To prevent security breaches and future breakage. | GIVEN users with `mysql_native_password`, WHEN I run MySQLTuner, THEN it shows a warning. |
40+
| MySQL 9.0 Readiness | P1 | As a DBA, I want to know if my users are ready for MySQL 9.0. | `mysql_native_password` is removed in 9.0. | GIVEN MySQL 8.x, WHEN I run MySQLTuner, THEN it flags accounts needing migration for 9.0. |
41+
42+
## Implementation Plan
43+
44+
1. Query `mysql.user` (or `information_schema.USER_PRIVILEGES` / `information_schema.applicable_roles` depending on version).
45+
2. For each account, check `plugin` column.
46+
3. Aggregate findings and display in "Security Recommendations".
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Documentation Synchronization Enhancement
3+
status: draft
4+
project: MySQLTuner-perl
5+
---
6+
7+
# Documentation Synchronization Enhancement
8+
9+
## 🧠 Rationale
10+
11+
To maintain high-quality, professional standards, all project documentation (READMEs, Roadmaps, Potential Issues, and internal script comments) must be synchronized with the latest functional changes and versioning. This prevents "documentation rot" and ensures users and contributors always have the most accurate information.
12+
13+
## 🛠️ Implementation
14+
15+
### 1. Workflow Update
16+
17+
The `/doc-sync` workflow in `.agent/workflows/doc-sync.md` will be expanded to include explicit steps for:
18+
19+
- Updating English and international `README.md` files.
20+
- Synchronizing usage information with `CLI_METADATA`.
21+
- Updating `ROADMAP.md` based on completed features in `Changelog`.
22+
- Auditing `POTENTIAL_ISSUES` to ensure resolved items are marked or removed.
23+
- Ensuring script comments (internal documentation) accurately reflect logic changes.
24+
25+
### 2. Synchronization Checklist
26+
27+
A new "Synchronization Checklist" will be added to the workflow to ensure:
28+
29+
- `CURRENT_VERSION.txt` matches `mysqltuner.pl` `$tunerversion`.
30+
- `Changelog` header matches the current version and date.
31+
- `releases/v[VERSION].md` exists and summarizes the release correctly.
32+
- All versioned POD documentation in `mysqltuner.pl` is updated.
33+
34+
## ✅ Verification
35+
36+
- Manual verification of documentation consistency.
37+
- Successful execution of `doc_sync.py`.
38+
- Validation of version strings across all 5 mandatory locations (CURRENT_VERSION.txt, script header, $VERSION variable, POD, Changelog).
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Specification: MySQL 9.x Support
2+
3+
## Feature Name: MySQL 9.x Ecosystem Support
4+
5+
**Status**: Draft
6+
**Created Date**: 2026-02-14
7+
8+
## Goal
9+
10+
Ensure `mysqltuner.pl` is fully compatible with MySQL 9.x, handling removed variables and new defaults.
11+
12+
## Key Changes in MySQL 9.x
13+
14+
### Removed Components
15+
16+
- `mysql_native_password` authentication plugin.
17+
- Many deprecated system variables from 8.x.
18+
19+
### New Features to Support
20+
21+
- New performance_schema tables for monitoring.
22+
- Updates to InnoDB defaults and internal structures.
23+
24+
## User Stories
25+
26+
| Title | Priority | Description | Rationale | Test Case |
27+
| :--- | :--- | :--- | :--- | :--- |
28+
| Version Detection | P1 | As a user, I want MySQLTuner to correctly recognize MySQL 9.x. | To ensure version-specific advice is correct. | GIVEN MySQL 9.0, WHEN I run MySQLTuner, THEN it identifies the version correctly. |
29+
| Handle Removals | P1 | As a user, I want MySQLTuner to NOT try and use removed features. | To avoid SQL errors or crashes. | GIVEN MySQL 9.0, WHEN I run MySQLTuner, THEN it skips checks for `mysql_native_password`. |
30+
31+
## Implementation Plan
32+
33+
1. Update version detection logic in `mysqltuner.pl`.
34+
2. Audit all existing checks for features removed in 9.x.
35+
3. Add specific advice for 9.x performance optimizations.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Specification - Syslog and Systemd Journal Support for MariaDB/MySQL
2+
3+
## 🧠 Rationale
4+
5+
On modern Linux distributions (like Ubuntu 18.04+), MariaDB and MySQL often default to logging via the systemd journal or syslog instead of a traditional error log file. When `log_error` is not set or points to an unreadable file, MySQLTuner currently fails to analyze logs. This feature adds automatic detection of systemd journal and syslog as fallback sources for error logs.
6+
7+
## User Scenarios
8+
9+
- **Scenario 1**: A user installs MariaDB 10.3 on Ubuntu 18.04. The default configuration logs to systemd. MySQLTuner detects that the traditional log file is missing or empty and automatically switches to `journalctl` to fetch logs.
10+
- **Scenario 2**: A user has a legacy system where logs are directed to `/var/log/syslog`. MySQLTuner checks this file as a last resort if other methods fail.
11+
12+
## User Stories
13+
14+
| Title | Priority | Description | Rationale | Test Case |
15+
| :--- | :--- | :--- | :--- | :--- |
16+
| Systemd Detection | P1 | As a script, I want to automatically detect if MariaDB/MySQL logs are in the systemd journal. | Simplify log analysis on modern systems. | GIVEN a system with `journalctl` and `mariadb.service`, WHEN `log_error` is missing, THEN use `journalctl`. |
17+
| Syslog Fallback | P2 | As a script, I want to check `/var/log/syslog` if no other log source is found. | Provide a fallback for systems using traditional syslog. | GIVEN `/var/log/syslog` exists and contains `mysqld` entries, WHEN other logs fail, THEN use syslog. |
18+
| Automatic Prefixing | P1 | As a script, I want to automatically use `systemd:<service>` prefix for log analysis. | Leverage existing systemd journal reading logic. | GIVEN `mariadb` service is active, WHEN log analysis starts, THEN `log_error` is set to `systemd:mariadb`. |
19+
20+
## Technical Implementation Details
21+
22+
- **Service Detection**: Check for `mariadb.service` or `mysql.service` using `systemctl` if available.
23+
- **Fallback Logic in `log_file_recommendations`**:
24+
1. Check `log_error` variable.
25+
2. Check Performance Schema `error_log` table.
26+
3. Check traditional file paths (existing logic).
27+
4. **NEW**: Check `journalctl` for `mariadb` or `mysql` units.
28+
5. **NEW**: Check `/var/log/syslog` if it contains `mysqld` or `mariadb` entries.
29+
- **Command Abstraction**: Use `execute_system_command` for all external calls.
30+
31+
## Verification
32+
33+
- Simulate systemd logs in a test environment.
34+
- Verify that `systemd:` prefix correctly triggers `journalctl` calls.
35+
- Verify that syslog fallback works when files are readable.

0 commit comments

Comments
 (0)