|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80904 non-atomic behaviour when changing symlinked doc-root
Submitted: 2021-03-24 17:23 UTC Modified: 2021-03-24 17:28 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: maggus dot staab+php at googlemail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 7.4.16 OS: ubuntu linux 20 lts
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2021-03-24 17:23 UTC] maggus dot staab+php at googlemail dot com
we are experiencing errors when deploying new code/updates onto our servers.

these are rare errors which happen after the deployment tool swaps the doc-root symlink. we are using a popular deployment tool from

I guess what triggers our error can be described as the following
- http request are comig in
- apache server receives the request, resolves the doc-root symlink and starts processing the request with version A of our codebase
- a deployment happens which swaps the symlink of the doc-root to version A+1
- the request, which was started before, realizes the symlink switched and while serving a request now picks up changes from app version A+1

this leads to errors like "Cannot redeclare function", "class already defined" and sometimes we even see errors like out-of-memory.

from our error reporting its pretty clear that requests mix classes from codebase in version A and version A+1:

App Path:           /www/myapp/releases/234/app/www-phone
Request-Id:         118c703

Exception:          'ErrorException' with message 'Cannot redeclare renderTrackableOrderBySelect() (previously declared in /www/myapp/releases/234/vendor/plugins/clxMobileNetPortable/lib/portable/helpers/ViewHelper.php:442)' (1)

the stacktrace from this error contains the path to version A+1, while the initial App-Path which is set very early in the bootsrap as a php constant, was defined as Version A.

I feel/guess the problem we experience is the one which rasmus created this apache module for:

in our setup we are running php in mpm event mode, which the mentioned apache module does not work with (per README notes).
the underlying issue seems to be discussed here:

I hope for some inspiration/pointers on how this problem could be tackled or which tools/mods should/can be used to circumvent the problem reported.

feel free to ask further questions in case I missed some important information

Test script:
the errors happen only from time to time and cannot be reproduced easily.
I guess I can not really provide a test-script.

Expected result:
a php request should be atomic and should not change the doc-root while the request is running


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-24 17:28 UTC] maggus dot staab+php at googlemail dot com
it seems I cannot edit the initial bug description, therefore here a small correction.

our error reporting shows

App Path:           /www/myapp/releases/233/app/www-phone
Request-Id:         118c703

Exception:          'ErrorException' with message 'Cannot redeclare renderTrackableOrderBySelect() (previously declared in /www/myapp/releases/234/vendor/plugins/clxMobileNetPortable/lib/portable/helpers/ViewHelper.php:442)' (1)

see different app revision in 'App Path' vs. 'Exception Stack Trace'.
in the initial report I copy & paste'd the wrong numbers.
 [2021-04-22 09:31 UTC] maggus dot staab+php at googlemail dot com
after reading

I stumbled over "opcache.dups_fix bool  - This hack should only be enabled to work around "Cannot redeclare class" errors. "

should I activate this flag because of the errors I see?
or will it just ignore the errors but still get stuck?
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 03:01:28 2024 UTC