Skip to content

Commit 0696e8a

Browse files
authored
Merge pull request #873 from jmrenouard/master
v2.8.27
2 parents 71f5a41 + 3f740fc commit 0696e8a

11 files changed

Lines changed: 713 additions & 138 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Database Version Rift Skill
2+
3+
## Description
4+
5+
This skill maps critical differences between MySQL and MariaDB versions to help developers implement cross-compatible diagnostics in MySQLTuner.
6+
7+
## Replication Commands
8+
9+
| Feature | MySQL < 8.0.22 / MariaDB < 10.5 | MySQL >= 8.0.22 | MariaDB >= 10.5 |
10+
| :--- | :--- | :--- | :--- |
11+
| **Show Slave Status** | `SHOW SLAVE STATUS` | `SHOW REPLICA STATUS` (Preferred) | `SHOW REPLICA STATUS` (Preferred) |
12+
| **Show Slave Hosts** | `SHOW SLAVE HOSTS` | `SHOW REPLICA HOSTS` | `SHOW REPLICA HOSTS` |
13+
14+
**Strategy:**
15+
Detect version first. If version >= breakpoint, try `REPLICA`, fall back to `SLAVE` if error or empty (though strictly version check is safer).
16+
17+
## Authentication & Security
18+
19+
| Feature | MySQL 5.7 / MariaDB | MySQL 8.0+ |
20+
| :--- | :--- | :--- |
21+
| **PASSWORD() function**| Available | **REMOVED** (Use SHA2 functions or app-side hashing) |
22+
| **User table** | `mysql.user` (authentication_string since 5.7) | `mysql.user` (authentication_string) |
23+
24+
**Strategy:**
25+
For password checks in MySQL 8.0+, do strictly SQL-based checks (e.g., length of auth string) or avoid logic that depends on hashing input strings via SQL.
26+
27+
## Information Schema Differences
28+
29+
### `information_schema.TABLES`
30+
31+
- Usually stable, but check `Data_free` interpretation across engines.
32+
33+
### `performance_schema`
34+
35+
- **MySQL 5.6+**: Defaults enabled (mostly).
36+
- **MariaDB 10.0+**: Defaults varying.
37+
- **Check**: Always verify `performance_schema = ON` before querying tables.
38+
39+
## System Variables (Renames)
40+
41+
| Legacy Name | Modern Name (MySQL 8.0+) | Note |
42+
| :--- | :--- | :--- |
43+
| `tx_isolation` | `transaction_isolation` | Check both or `||` them. |
44+
| `query_cache_size` | *Removed* | Removed in MySQL 8.0 |
45+
46+
**Strategy:**
47+
Use the `mysqltuner.pl` valid variable abstraction or check for existence before using.
48+
49+
## MariaDB vs MySQL Divergence
50+
51+
- **Thread Pool**:
52+
- **MariaDB**: Built-in, specific vars (`thread_pool_size`, `thread_pool_oversubscribe`).
53+
- **MySQL**: Enterprise only or Percona specific.
54+
- **Action**: Check `version_comment` or `version` string for "MariaDB" before recommending thread pool settings.
55+
56+
- **Aria Engine**:
57+
- Specific to MariaDB (replacement for MyISAM for system tables).
58+
- Don't tune `aria_pagecache_buffer_size` on Oracle MySQL.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Legacy Perl Patterns Skill
2+
3+
## Description
4+
5+
This skill provides guidelines and patterns for writing Perl code that maintains backward compatibility with older Perl versions (down to 5.8) as required by the MySQLTuner project constitution.
6+
7+
## Anti-Patterns (Avoid)
8+
9+
### 1. `say` (Perl 5.10+)
10+
11+
**Wrong:**
12+
13+
```perl
14+
use feature 'say';
15+
say "Hello";
16+
```
17+
18+
**Right:**
19+
20+
```perl
21+
print "Hello\n";
22+
```
23+
24+
### 2. `state` variables (Perl 5.10+)
25+
26+
**Wrong:**
27+
28+
```perl
29+
use feature 'state';
30+
sub foo {
31+
state $x = 0;
32+
$x++;
33+
}
34+
```
35+
36+
**Right:**
37+
38+
```perl
39+
{
40+
my $x = 0;
41+
sub foo {
42+
$x++;
43+
}
44+
}
45+
```
46+
47+
### 3. Defined-or operator `//` (Perl 5.10+)
48+
49+
**Wrong:**
50+
51+
```perl
52+
my $a = $b // $c;
53+
```
54+
55+
**Right:**
56+
57+
```perl
58+
my $a = defined($b) ? $b : $c;
59+
```
60+
61+
### 4. `given` / `when` (Switch statements)
62+
63+
**Wrong:**
64+
65+
```perl
66+
given ($foo) { when(1) { ... } }
67+
```
68+
69+
**Right:**
70+
71+
```perl
72+
if ($foo == 1) { ... }
73+
elsif ($foo == 2) { ... }
74+
```
75+
76+
## Safe Patterns (Recommended)
77+
78+
### 1. Three-argument `open`
79+
80+
Always use the 3-arg form of open for safety, but check support if targeting extremely old perl (pre-5.6), though 5.8 is our floor.
81+
82+
```perl
83+
open(my $fh, '<', $filename) or die "Cannot open $filename: $!";
84+
```
85+
86+
### 2. Modular compatibility
87+
88+
Avoid `use Module::Name` if the module wasn't core in 5.8.
89+
Check `corelist` if unsure.
90+
Example: `Time::HiRes` is core since 5.8.
91+
92+
### 3. Regex
93+
94+
Avoid 5.10+ regex extensions (e.g. named capture groups `(?<name>...)` unless you are sure). Use standard capturing parentheses `(...)`.
95+
96+
## Validation
97+
98+
Always test syntax with a lower version of perl if available, or rely on strict `make test` environment containers that might emulate older setups.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
description: Automated audit to enforce project constitution rules
3+
---
4+
5+
# Compliance Sentinel
6+
7+
This workflow acts as a static analysis guardrail to ensure "Constitution" compliance.
8+
9+
## 1. Core Check: Single File Architecture
10+
11+
Ensure no additional Perl modules (.pm) have been added to the root or lib dirs intended for distribution.
12+
13+
```bash
14+
if [ $(find . -maxdepth 2 -name "*.pm" | wc -l) -gt 0 ]; then
15+
echo "FAIL: No .pm files allowed. Architecture must remain Single File."
16+
exit 1
17+
fi
18+
```
19+
20+
## 2. Core Check: Zero Dependency (Standard Core Only)
21+
22+
Scan for non-core CPAN modules.
23+
24+
```bash
25+
# Allow-list (examples of standard modules)
26+
# strict, warnings, Getopt::Long, File::Basename, Data::Dumper, POSIX, etc.
27+
# Grep for 'use' and manually review or verify against `corelist`.
28+
grep "^use " mysqltuner.pl | sort | uniq
29+
```
30+
31+
## 3. Core Check: Syscall Protection
32+
33+
Verify that system calls are safe.
34+
35+
```bash
36+
# Look for potential unsafe system calls (qx, ``, system)
37+
grep -nE "qx/|`|system\(" mysqltuner.pl
38+
# Manual Review: Ensure each is wrapped or checked.
39+
```
40+
41+
## 4. Changelog Compliance
42+
43+
Verify the format of the latest Changelog entries.
44+
45+
```bash
46+
head -n 20 Changelog
47+
# Must follow:
48+
# X.Y.Z YYYY-MM-DD
49+
# - type: description
50+
```
51+
52+
## 5. Execution
53+
54+
Run these checks before any major commit or release.

.agent/workflows/docker-clean.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
description: /docker-clean
3+
---
4+
5+
---
6+
7+
description: Reclaim disk space by removing unused containers and images
8+
---
9+
10+
1. **Check Current Usage**:
11+
- See how much space Docker is using.
12+
// turbo
13+
- Run `docker system df`
14+
15+
2. **Run Prune**:
16+
- ⚠️ **WARNING**: This will remove all stopped containers and unused images!
17+
- Remove all stopped containers, unused networks, and dangling images.
18+
// turbo
19+
- Run `docker system prune -a`
20+
21+
3. **Verify Space Reclaimed**:
22+
- Check the new disk usage.
23+
// turbo
24+
- Run `docker system df`
25+
26+
4. **Pro Tips**:
27+
- Add `--volumes` to also delete unused volumes (DATA LOSS WARNING!).
28+
- To remove only dangling images: `docker image prune`.
29+
- Set up automatic cleanup: add `"log-opts": {"max-size": "10m"}` to Docker daemon config.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
description: Pre-flight checks before triggering a git-flow release
3+
---
4+
5+
# Release Preflight Workflow
6+
7+
Ensure consistency across versioning artifacts before cutting a release.
8+
9+
## 1. Extract Versions
10+
11+
```bash
12+
# 1. mysqltuner.pl internal version
13+
SCRIPT_VER=$(grep "mysqltuner.pl v" mysqltuner.pl | head -n 1 | awk '{print $2}' | sed 's/v//')
14+
15+
# 2. CURRENT_VERSION.txt
16+
TXT_VER=$(cat CURRENT_VERSION.txt)
17+
18+
# 3. Changelog latest version
19+
LOG_VER=$(head -n 1 Changelog | awk '{print $1}')
20+
```
21+
22+
## 2. Validate Consistency
23+
24+
All three versions must match.
25+
26+
```bash
27+
if [ "$SCRIPT_VER" == "$TXT_VER" ] && [ "$TXT_VER" == "$LOG_VER" ]; then
28+
echo "SUCCESS: Versions match ($SCRIPT_VER)."
29+
else
30+
echo "FAIL: Version Mismatch!"
31+
echo "Script: $SCRIPT_VER"
32+
echo "Txt: $TXT_VER"
33+
echo "Changelog: $LOG_VER"
34+
exit 1
35+
fi
36+
```
37+
38+
## 3. Smoke Test
39+
40+
Run the primary test suite to ensure the build isn't broken.
41+
42+
```bash
43+
# Assuming make test exists and runs the suite
44+
make test
45+
```
46+
47+
## 4. Proceed to Release
48+
49+
If all checks pass, proceed with `/git-flow`.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
description: Transform a running production issue into a reproducible test case
3+
---
4+
5+
# Snapshot to Test Workflow
6+
7+
This workflow helps capture the state of a running database (where a bug is observed) and converts it into a standalone Perl test case for TDD.
8+
9+
## 1. Context Acquisition
10+
11+
Identify the target container or host where the issue is reproducible.
12+
13+
```bash
14+
# Example: Define target
15+
TARGET_CONTAINER="mysql_8_0"
16+
```
17+
18+
## 2. Capture Variables and Status
19+
20+
Extract the raw data required by MySQLTuner to mock the environment.
21+
22+
```bash
23+
# Extract Global Variables
24+
docker exec -i $TARGET_CONTAINER mysql -NBe "SHOW GLOBAL VARIABLES" > /tmp/vars.txt
25+
26+
# Extract Global Status
27+
docker exec -i $TARGET_CONTAINER mysql -NBe "SHOW GLOBAL STATUS" > /tmp/status.txt
28+
```
29+
30+
## 3. Generate Test Skeleton
31+
32+
Create a new test file in `tests/` (e.g., `tests/repro_issue_XXX.t`).
33+
34+
Use the following template:
35+
36+
```perl
37+
#!/usr/bin/env perl
38+
use strict;
39+
use warnings;
40+
use Test::More;
41+
use Data::Dumper;
42+
43+
# 1. Load MySQLTuner logic
44+
# (Adjust path if needed to load specific subroutines)
45+
require 'mysqltuner.pl';
46+
47+
# 2. Mock Data
48+
# Insert data captured from /tmp/vars.txt and /tmp/status.txt
49+
my %mock_variables = (
50+
# ... content from vars.txt formatted as hash ...
51+
'version' => '8.0.32',
52+
'innodb_buffer_pool_size' => '1073741824',
53+
);
54+
55+
my %mock_status = (
56+
# ... content from status.txt formatted as hash ...
57+
'Uptime' => '3600',
58+
'Questions' => '500',
59+
);
60+
61+
# 3. Setup Environment
62+
# Overlay mock data onto the script's global hashes
63+
*main::myvar = \%mock_variables;
64+
*main::mystat = \%mock_status;
65+
66+
# 4. Execute Logic
67+
# Call the specific subroutine under test
68+
# e.g., setup_innodb_buffer_pool();
69+
70+
# 5. Assertions
71+
# Verify the expected behavior (bug reproduction or fix verification)
72+
ok(1, "Placeholder assertion");
73+
74+
done_testing();
75+
```
76+
77+
## 4. Run and Refine
78+
79+
Run the test to confirm it fails (if reproducing a bug) or passes (if verifying logic).
80+
81+
```bash
82+
prove tests/repro_issue_XXX.t
83+
```

CURRENT_VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.8.25
1+
2.8.27

0 commit comments

Comments
 (0)