Wrong memory percentage on /admin/reports/redis

Created on 12 January 2021, over 3 years ago
Updated 31 October 2023, 8 months ago

Problem/Motivation

        '@used_percentage' => (int) ($info['used_memory'] ?? $info['Memory']['used_memory'] / $memory_config['maxmemory'] * 100),

The origin code is interpreted to

$used_percentage;
 
if (!isset($info['used_memory'])) {
   $used_percentage = (int) ($info['Memory']['used_memory'] / $memory_config['maxmemory'] * 100)
}
else {
  $used_percentage = (int) $info['used_memory'];
}

Steps to reproduce

Proposed resolution

Add () to $info['used_memory'] ?? $info['Memory']['used_memory']

        '@used_percentage' => (int) (($info['used_memory'] ?? $info['Memory']['used_memory']) / $memory_config['maxmemory'] * 100),

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡³China jungle Chongqing, China

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia ThomWilhelm Sydney

    +1, just adding a patch here for people using composer patches.

    Hopefully this can get merged!

  • πŸ‡¬πŸ‡§United Kingdom Alina Basarabeanu

    Patch from #10 fixed the issue in Drupal Version 9.5.10 and redis 1.7.0.
    Can this be merged into the next stable release?
    Thank you

  • πŸ‡³πŸ‡±Netherlands Dobefu

    I feel like this solution is not very future-proof, as it casts any data type to an integer. This would mean that the percentage would also break in the event that you set the max memory to 1GB and the amount used is in MBs. I feel like the solution would be to first parse the values to their count in bytes.

Production build 0.69.0 2024