Bug #80904 [Com]: non-atomic behaviour when changing symlinked doc-root

From: Date: Wed, 16 Jun 2021 01:39:43 +0000
Subject: Bug #80904 [Com]: non-atomic behaviour when changing symlinked doc-root
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234424@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80904&edit=1

 ID:                 80904
 Comment by:         yagnajee007 at gmail dot com
 Reported by:        maggus dot staab+php at googlemail dot com
 Summary:            non-atomic behaviour when changing symlinked
                     doc-root
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 Operating System:   ubuntu linux 20 lts
 PHP Version:        7.4.16
 Block user comment: N
 Private report:     N

 New Comment:

A second deploy to push the changes to make use of the new code and a final. It is also too
PHP-oriented in that it relies on very specific PHP behaviour. This allows us to make the document
root a symlink which we can toggle. Such mechanisms are also not request-aware so a server with
multiple.regards - https://ghdsportsapk.xyz/ghd-sports-download/
If you do not specify "nonatomic", then the property is atomic, but you can still. If the
instance variable is not gonna be changed by multiple threads you can use it.


Previous Comments:
------------------------------------------------------------------------
[2021-04-22 09:31:38] maggus dot staab+php at googlemail dot com

after reading https://www.php.net/manual/de/opcache.configuration.php#ini.opcache.file_update_protection

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?

------------------------------------------------------------------------
[2021-03-24 17:28:39] 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-03-24 17:23:52] maggus dot staab+php at googlemail dot com

Description:
------------
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 https://deployer.org/

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: https://github.com/etsy/mod_realdoc

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: https://github.com/etsy/mod_realdoc/issues/4

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



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80904&edit=1


Thread (4 messages)

« previous php.bugs (#234424) next »