Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Database/Advisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Advisor {
'Query_cache_efficiency',
'Key_buffer_hit_rate',
'Table_locks_waited',
'Table_open_cache',
'Binlog_cache_disk_use',
'Slow_query_rate',
'Sort_rows',
Expand Down
31 changes: 31 additions & 0 deletions tests/lib/Database/AdvisorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,37 @@ public function testReplicaLagFailsOnStoppedReplica(): void {
$this->assertSame(RuleResult::STATUS_FAIL, $result->status);
}

/**
* Table_open_cache derives from counters that reset with the server, so
* the cold-start opens dominate the ratio for hours after a restart. It
* belongs behind the same uptime gate as the other hit-rate rules.
*/
public function testTableOpenCacheSkippedOnFreshlyRestartedServer(): void {
$status = [
'Uptime' => 3600,
'Table_open_cache_hits' => 3411,
'Table_open_cache_misses' => 87,
];
$derived = ['Uptime_hours' => 1.0, 'Uptime_days' => 1.0 / 24.0];

$snapshot = new Snapshot(
Snapshot::FLAVOUR_MARIADB,
'11.8.8-MariaDB',
$status,
['table_open_cache' => 4000],
$derived + ['value' => 0.0],
);

foreach ($this->advisor->run(new Mysql(), $snapshot) as $result) {
if ($result->rule->id === 'Table_open_cache') {
$this->assertSame(RuleResult::STATUS_SKIPPED, $result->status);
return;
}
}

$this->fail("Rule 'Table_open_cache' was not evaluated");
}

/**
* A healthy replica must not be flagged.
*/
Expand Down
Loading