php / php-src

The PHP Interpreter
https://www.php.net
Other
37.96k stars 7.73k forks source link

Weird systemctl status phpX.Y-fpm output on Ubuntu 22.04 #10204

Open datadestroyd opened 1 year ago

datadestroyd commented 1 year ago

Description

On Ubuntu 22.04, systemctl status phpX.Y-fpm.service shows the following weird output:

     CGroup: /system.slice/php8.1-fpm.service
             ├─ 3132 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             └─30747 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

I am not really sure what this is, but I don't think it's supposed to print all these quotation marks. It didn't happen on earlier LTS versions of Ubuntu. Maybe it is related to the systemd version that ships with Ubuntu 22.04 (which is 249.11). The same thing happens with packages from Ondřej Surýs PPA.

Steps to reproduce:

PHP Version

8.* and 7.4

Operating System

Ubuntu 22.04

devnexen commented 1 year ago

can reproduce on 22.04 indeed not on 22.10.

bukka commented 1 year ago

I just had a look to https://packages.ubuntu.com/jammy/amd64/php8.1-fpm and the php-fpm.service in it looks like

[Unit]
Description=The PHP @PHP_VERSION@ FastCGI Process Manager
Documentation=man:php-fpm@PHP_VERSION@(8)
After=network.target

[Service]
Type=notify
ExecStart=/usr/sbin/php-fpm@PHP_VERSION@ --nodaemonize --fpm-config /etc/php/@PHP_VERSION@/fpm/php-fpm.conf
ExecStartPost=-/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/@PHP_VERSION@/fpm/pool.d/www.conf @PHP_MAJOR@@PHP_MINOR@
ExecStopPost=-/usr/lib/php/php-fpm-socket-helper remove /run/php/php-fpm.sock /etc/php/@PHP_VERSION@/fpm/pool.d/www.conf @PHP_MAJOR@@PHP_MINOR@
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

So this is completely custom unit file in no way related to what we supply as sort of template in https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.service.in .

So this should be really reported to https://github.com/oerdnj/deb.sury.org as there's nothing we can do about this upstream.

datadestroyd commented 1 year ago

@bukka I fail to see what the unit file has to do with it. Especially since the files are exactly the same on the other Ubuntu releases where the issue does not occur. It seems to me that there might be something wrong with how the process titles are reported to systemd. But that's just a guess.

In any event, I downloaded the PHP source (master branch), compiled it myself, and started a service using the unit file generated by the build process. The result: the quotation marks also occur.

bukka commented 1 year ago

Ok I was just thinking that it might be related to the unit file somehow as the issue dissappeared in 22.10 but it might be more likely something related to systemd (maybe some bug that got fixed later) and potentially the process title. Anyway it needs some investigation so re-opening.

CxDevLead commented 1 year ago

Is this issue simply cosmetic?

The quotations caused quite a bit of head scratching when we updated to 22.04.

datadestroyd commented 1 year ago

I found that it also happens with redis-server on Ubuntu 22.04. So it might not be PHP's fault, but a systemd issue. No idea if it's purely cosmetic or if there is something more to it. I still think someone should have a look at this. As far as I can tell, the issue is provoked somewhere in fpm_env.c where the process title is set by somehow fiddling around with argv. In a comment they mention that the code is inspired by "nginx and pureftpd". So redis-server probably uses some similar technique to change the process title.

datadestroyd commented 1 year ago

After some further investigation I am now relatively convinced that this is a cosmetic issue. If you inspect /proc/$pid/cmdline (setting $pid to a PHP FPM process) the length of the file is much larger than the actual string, but the remainder is just a bunch of zero-bytes (0x00). I guess the length just stays the same as it was before the process title modification / argv fiddling. The same happens on, for instance, Ubuntu 18.04, only systemctl status does not display the zero-bytes as double double quotes, so you don't see it.

> xxd /proc/$pid/cmdline
00000000: 7068 702d 6670 6d3a 2070 6f6f 6c20 7777  php-fpm: pool ww
00000010: 7700 0000 0000 0000 0000 0000 0000 0000  w...............
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000       ..............

I wonder what happens if the process title is longer than the original argv string, tho... 🤔

bukka commented 5 months ago

I think there were potentially some changes in kernel cmdline implementation that got later changed back. It seems to me like that happened a bit earlier though but something likely changed back - one of the related commits is maybe https://github.com/torvalds/linux/commit/3d71254 but I haven't looked too deeply into this. In any case it seems that the issue is no longer present in the later versions. I think that 22.04 got also updated so it would be great if someone could verify if it's still present? If so, could you please provide your kernel version?

I tested on Fedora 39 (kernel-6.7.11) as well as Ubuntu 20.04 (kernel 5.15.0) and not able to recreate it.

As noted this won't be PHP specific and don't think it's worth of my time to look into it more if it's temporary kernel thing.

mitarulv commented 5 months ago

image

Still present 7.4. Got this after updating server OS from 20.04 to 22.04 without removing previous php-fpm installation aka packages were marked as manual:

apt-mark manual php7.4 php7.4-cli php7.4-common php7.4-curl php7.4-fpm php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-soap php7.4-xml php7.4-xmlrpc php7.4-zip 

Gonna try removing them and install clean version and check if does the trick.

P.S. Reinstalling didn't solve it still seeing quotes in php7.4-fpm status.

Knot1985 commented 1 month ago

Hello

I upgraded from Ubuntu 20.04 to 22.04 today and I have the same issue. I only made a do-release-upgrade Screenshot_1v

datadestroyd commented 1 month ago

It's a systemd issue: https://github.com/systemd/systemd/issues/21186

It will probably go away again in Ubuntu 24.04 (haven't checked yet).