Problem/Motivation

If $info['mem_size'] is empty this error occurs:

DivisionByZeroError: Division by zero in Drupal\monitoring\Plugin\monitoring\SensorPlugin\ApcuSharedMemorySizeSensorPlugin->runSensor() (line 47 of /app/web/modules/contrib/monitoring/src/Plugin/monitoring/SensorPlugin/ApcuSharedMemorySizeSensorPlugin.php).

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork monitoring-3540744

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

primsi created an issue. See original summary.

berdir’s picture

Status: Active » Needs work

Reviewed.

dieterholvoet’s picture

Status: Needs work » Needs review
dieterholvoet’s picture

Status: Needs review » Needs work

We have been encountering the same bug on a bunch of sites since tonight. In our case the current MR doesn't seem to solve the issue. Our problem is that ini_get('apc.shm_segments') returns FALSE, making $shm_size === 0 which still causes a DivisionByZeroError.

berdir’s picture

Thanks for the feedback, so it's not mem_size that's the problem then. Doesn't make sense to me that this would return FALSE, but lets check for that, maybe default the value to 1 if not set or skip the whole thing?

dieterholvoet’s picture

Status: Needs work » Needs review

Well I checked phpinfo() and the directive is missing. Haven't figured out how yet, I'm checking with our hosting partner, but it couldn't hurt checking for this situation. It's interesting that we're not the only one encountering this issue in the span of a couple days.

dieterholvoet’s picture

Not sure if the other check is actually necessary, I'll leave that to @primsi to determine.

  • berdir committed 88c7d96c on 8.x-1.x authored by primsi
    Issue #3540744 by primsi, dieterholvoet: DivisionByZeroError in...
berdir’s picture

Status: Needs review » Fixed

What's weird is that in our case (on platform.sh) the error went away after a redeploy and it only happened on one out of dozens of projects, so we can't reproduce it there anymore.

I've merged it for now.

With the Throwable change, even a DivisionByZeroError or another Error shouldn't break the monitoring page completely anymore, but it's useful to see a more specific reason than the error.

dieterholvoet’s picture

Status: Fixed » Needs work
Related issues: +#3538854: APCu requirement for 32MB always displays since APCu 5.1.25

Found the culprit. The issue was triggered by security updates last night. There's an associated core issue: #3538854: APCu requirement for 32MB always displays since APCu 5.1.25.

The apc.shm_segments ini option has been removed. Multiple SHM segments are no longer supported. (They were already not supported when using mmap, which is the default mode of operation)

Source

I suggest we add a fallback to 1 if the ini directive is missing.

berdir’s picture

Priority: Normal » Critical

Makes sense, lets open an new MR then for then. I'm also fine if we just drop that segment logic completely. Worst case is we report a wrong total, I don't really care too much, never used that feature, not as long as I can remember. I think I copied this from core.

It also means that this will hit all sites eventually, maybe platform.sh rolled back the apcu version due to that and that's why redeploy fixed it.

primsi’s picture

@dieterholvoet did you plan to work on this? Otherwise I can check this tomorrow.

dieterholvoet’s picture

Priority: Critical » Normal
Status: Needs work » Needs review

Already done!

dieterholvoet changed the visibility of the branch 8.x-1.x to hidden.

  • berdir committed 93e446f9 on 8.x-1.x authored by dieterholvoet
    Issue #3540744 by dieterholvoet, primsi, berdir: DivisionByZeroError in...
berdir’s picture

Status: Needs review » Fixed

Merged again.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.