1

My system is Ubuntu 18.04, Apache2, PHP 7.2. I have a very weird problem when I access FTP from Winscp or Filezilla.

The problem is after I terminate the FTP session and try to go to my website, I got this site can't be reached. I have to restart Apache2 to make the web site work again.

How can I solve this?

Apache logs:

[Wed Aug 29 12:26:20.658550 2018] [core:warn] [pid 6112] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Aug 29 12:26:20.664959 2018] [mpm_prefork:notice] [pid 6112] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.0h configured -- resuming normal operations
[Wed Aug 29 12:26:20.665014 2018] [core:notice] [pid 6112] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 29 12:27:27.563287 2018] [mpm_prefork:emerg] [pid 6121] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:27:27.566692 2018] [mpm_prefork:emerg] [pid 6120] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:27:27.571578 2018] [mpm_prefork:emerg] [pid 6125] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:27:27.573969 2018] [mpm_prefork:emerg] [pid 6129] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:27:27.577938 2018] [mpm_prefork:emerg] [pid 6128] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:27:27.744667 2018] [core:alert] [pid 6112] AH00050: Child 6120 returned a Fatal error... Apache is exiting!
[Wed Aug 29 12:27:27.744807 2018] [:emerg] [pid 6112] AH02818: MPM run failed, exiting
[Wed Aug 29 12:27:33.534483 2018] [core:warn] [pid 6425] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Aug 29 12:27:33.551045 2018] [mpm_prefork:notice] [pid 6425] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.0h configured -- resuming normal operations
[Wed Aug 29 12:27:33.551087 2018] [core:notice] [pid 6425] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 29 12:33:23.273811 2018] [mpm_prefork:notice] [pid 6425] AH00169: caught SIGTERM, shutting down
[Wed Aug 29 12:33:23.463364 2018] [mpm_prefork:notice] [pid 6566] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.0h configured -- resuming normal operations
[Wed Aug 29 12:33:23.463471 2018] [core:notice] [pid 6566] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 29 12:34:12.206500 2018] [mpm_prefork:emerg] [pid 6686] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:34:12.534263 2018] [core:alert] [pid 6566] AH00050: Child 6686 returned a Fatal error... Apache is exiting!
[Wed Aug 29 12:34:12.534321 2018] [:emerg] [pid 6566] AH02818: MPM run failed, exiting
[Wed Aug 29 12:34:12.536893 2018] [mpm_prefork:emerg] [pid 6689] (22)Invalid argument: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:34:12.539094 2018] [mpm_prefork:emerg] [pid 6688] (22)Invalid argument: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:36:21.687348 2018] [core:warn] [pid 9332] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Aug 29 12:36:21.709583 2018] [mpm_prefork:notice] [pid 9332] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.0h configured -- resuming normal operations
[Wed Aug 29 12:36:21.709650 2018] [core:notice] [pid 9332] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 29 12:39:10.500747 2018] [mpm_prefork:emerg] [pid 9347] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:39:10.502052 2018] [mpm_prefork:emerg] [pid 9336] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:39:10.507276 2018] [mpm_prefork:emerg] [pid 9337] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:39:10.509953 2018] [mpm_prefork:emerg] [pid 9338] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:39:10.514020 2018] [mpm_prefork:emerg] [pid 9346] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:39:10.522017 2018] [mpm_prefork:emerg] [pid 9343] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Wed Aug 29 12:39:10.850698 2018] [core:alert] [pid 9332] AH00050: Child 9336 returned a Fatal error... Apache is exiting!
[Wed Aug 29 12:39:10.851450 2018] [:emerg] [pid 9332] AH02818: MPM run failed, exiting
[Wed Aug 29 12:39:19.905390 2018] [core:warn] [pid 9605] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Aug 29 12:39:19.924748 2018] [mpm_prefork:notice] [pid 9605] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.0h configured -- resuming normal operations
[Wed Aug 29 12:39:19.924789 2018] [core:notice] [pid 9605] AH00094: Command line: '/usr/sbin/apache2'
3
2

I found the solution, resolution:

Connect to the server using SSH. Edit /etc/apache2/apache2.conf file setting:

Mutex posixsem

instead of Mutex file:${APACHE_LOCK_DIR} default

Restart apache service:

service apache2 restart
1
2

Let me add a bit to you answer Fathey Abdel Slam. From here:

A mutex is the basic synchronization method used within Traffic Server to protect data from simultaneous access by multiple threads. A mutex acts as a lock that protects data in one program thread from being accessed by another thread.

And from /etc/apache2/apache2.conf:

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.

The following mutex mechanisms are available:

  • default | yes

    This selects the default locking implementation, as determined by APR. The default locking implementation can be displayed by running httpd with the -V option.

  • none | no

    This effectively disables the mutex, and is only allowed for a mutex if the module indicates that it is a valid choice. Consult the module documentation for more information.

  • posixsem

    This is a mutex variant based on a Posix semaphore.

    Warning

    The semaphore ownership is not recovered if a thread in the process holding the mutex segfaults, resulting in a hang of the web server.

  • sysvsem

    This is a mutex variant based on a SystemV IPC semaphore. Warning

    It is possible to "leak" SysV semaphores if processes crash before the semaphore is removed. Security

    The semaphore API allows for a denial of service attack by any CGIs running under the same uid as the webserver (i.e., all CGIs, unless you use something like suexec or cgiwrapper).

  • sem

    This selects the "best" available semaphore implementation, choosing between Posix and SystemV IPC semaphores, in that order.

  • pthread

    This is a mutex variant based on cross-process Posix thread mutexes. Warning

    On most systems, if a child process terminates abnormally while holding a mutex that uses this implementation, the server will deadlock and stop responding to requests. When this occurs, the server will require a manual restart to recover.

    Solaris and Linux are notable exceptions as they provide a mechanism which usually allows the mutex to be recovered after a child process terminates abnormally while holding a mutex.

    If your system is POSIX compliant or if it implements the pthread_mutexattr_setrobust_np() function, you may be able to use the pthread option safely.

  • fcntl:/path/to/mutex

    This is a mutex variant where a physical (lock-)file and the fcntl() function are used as the mutex. Warning

    When multiple mutexes based on this mechanism are used within multi-threaded, multi-process environments, deadlock errors (EDEADLK) can be reported for valid mutex operations if fcntl() is not thread-aware, such as on Solaris.

  • flock:/path/to/mutex

    This is similar to the fcntl:/path/to/mutex method with the exception that the flock() function is used to provide file locking.

  • file:/path/to/mutex

    This selects the "best" available file locking implementation, choosing between fcntl and flock, in that order.

Most mechanisms are only available on selected platforms, where the underlying platform and APR support it. Mechanisms which aren't available on all platforms are posixsem, sysvsem, sem, pthread, fcntl, flock, and file.

With the file-based mechanisms fcntl and flock, the path, if provided, is a directory where the lock file will be created. The default directory is httpd's run-time file directory relative to ServerRoot. Always use a local disk filesystem for /path/to/mutex and never a directory residing on a NFS- or AFS-filesystem.

The basename of the file will be the mutex type, an optional instance string provided by the module, and unless the OmitPID keyword is specified, the process id of the httpd parent process will be appended to make the file name unique, avoiding conflicts when multiple httpd instances share a lock file directory.

For example, if the mutex name is mpm-accept and the lock file directory is /var/httpd/locks, the lock file name for the httpd instance with parent process id 12345 would be /var/httpd/locks/mpm-accept.12345.

Source:

http://httpd.apache.org/docs/2.4/mod/core.html#mutex

https://docs.trafficserver.apache.org/en/4.2.x/sdk/mutex-guide.en.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.