Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.4 wrong fpmstatus output #16932

Closed
PLTytus opened this issue Nov 25, 2024 · 4 comments
Closed

8.4 wrong fpmstatus output #16932

PLTytus opened this issue Nov 25, 2024 · 4 comments

Comments

@PLTytus
Copy link

PLTytus commented Nov 25, 2024

Description

fpmstatus seems to return wrong values, sample

pool:                 www
process manager:      dynamic
start time:           25/Nov/2024:13:00:38 +0000
start since:          5057
accepted conn:        1
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       0 
active processes:     1
total processes:      1
max active processes: 11
max children reached: 0
slow requests:        0
memory peak:          81326080

accepted conn not incresing, even decreasing, e.g. shows 3 after refreshing it shows 1 again
idle processes, active processes, idle processes: in this example there 15 running fpm processes in total

PHP Version

8.4.1

Operating System

No response

@devnexen
Copy link
Member

We might need a bit more to understand if the issue is relevant, i.e. configuration, how the logs look ...

@PLTytus
Copy link
Author

PLTytus commented Nov 25, 2024

This is in /usr/local/etc/php-fpm.d/www.conf on php:8.4.1-fpm-alpine image

[www]
user = www-data
group = www-data

pm = dynamic
pm.max_children = 200
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.max_requests = 200

pm.status_listen = 127.0.0.1:9001
pm.status_path = /fpmstatus

No errors in logs.

It kind of behaves like processes are overriding current stats: https://github.com/user-attachments/assets/61aab54b-2d25-45c7-b0d7-7562b8aaef2b

There is no such issue on PHP 8.3

@lucasnetau
Copy link
Contributor

lucasnetau commented Nov 26, 2024

Possibly this PR #14153

fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);

This is calling FPM_SCOREBOARD_ACTION_SET at the end of the request with all stats set to 0, the unmodified stats should be set as -1

so either don't set the values

--- fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
+++ fpm_scoreboard_update_commit(-1, -1, -1, -1, -1, -1, -1, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);

or INC vs SET

--- fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
+++ fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_INC, NULL);

@PLTytus
Copy link
Author

PLTytus commented Nov 26, 2024

Looking at fpm_scoreboard_update_commit definition, both @lucasnetau suggested solutions should resolve the issue.

void fpm_scoreboard_update_commit(
int idle, int active, int lq, int lq_len, int requests, int max_children_reached,
int slow_rq, size_t memory_peak, int action, struct fpm_scoreboard_s *scoreboard) /* {{{ */
{
scoreboard = fpm_scoreboard_get_for_update(scoreboard);
if (!scoreboard) {
return;
}
if (action == FPM_SCOREBOARD_ACTION_SET) {
if (idle >= 0) {
scoreboard->idle = idle;
}
if (active >= 0) {
scoreboard->active = active;
}
if (lq >= 0) {
scoreboard->lq = lq;
}
if (lq_len >= 0) {
scoreboard->lq_len = lq_len;
}
#if HAVE_FPM_LQ /* prevent unnecessary test */
if (scoreboard->lq > scoreboard->lq_max) {
scoreboard->lq_max = scoreboard->lq;
}
#endif
if (requests >= 0) {
scoreboard->requests = requests;
}
if (max_children_reached >= 0) {
scoreboard->max_children_reached = max_children_reached;
}
if (slow_rq > 0) {
scoreboard->slow_rq = slow_rq;
}
} else {
if (scoreboard->idle + idle > 0) {
scoreboard->idle += idle;
} else {
scoreboard->idle = 0;
}
if (scoreboard->active + active > 0) {
scoreboard->active += active;
} else {
scoreboard->active = 0;
}
if (scoreboard->requests + requests > 0) {
scoreboard->requests += requests;
} else {
scoreboard->requests = 0;
}
if (scoreboard->max_children_reached + max_children_reached > 0) {
scoreboard->max_children_reached += max_children_reached;
} else {
scoreboard->max_children_reached = 0;
}
if (scoreboard->slow_rq + slow_rq > 0) {
scoreboard->slow_rq += slow_rq;
} else {
scoreboard->slow_rq = 0;
}
}
if (scoreboard->active > scoreboard->active_max) {
scoreboard->active_max = scoreboard->active;
}
if (scoreboard->memory_peak < memory_peak) {
scoreboard->memory_peak = memory_peak;
}
fpm_unlock(scoreboard->lock);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants