Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107724 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81289 invoked from network); 28 Oct 2019 23:43:30 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 28 Oct 2019 23:43:30 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 8249D2D19B1 for ; Mon, 28 Oct 2019 14:30:58 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: No Received: from vsp01-out.oderland.com (vsp01-out.oderland.com [IPv6:2a02:28f0::24:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Mon, 28 Oct 2019 14:30:57 -0700 (PDT) X-Scanned-Cookie: bb4ff68a6d12a3c9857200220a8bcc59d3680b00 Received: from server10.serverdrift.com (unknown [91.201.60.110]) by vsp-out.oderland.com (Halon) with ESMTPSA id 37ece410-f9ca-11e9-b330-01199f35d292; Mon, 28 Oct 2019 22:30:52 +0100 (CET) Received: from 78-73-69-100-no96.tbcn.telia.com ([78.73.69.100]:52382 helo=[192.168.2.143]) by server10.serverdrift.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1iPCbE-0004BK-FV for internals@lists.php.net; Mon, 28 Oct 2019 22:30:52 +0100 To: internals@lists.php.net References: Message-ID: <119c7c14-0314-94e7-ca70-a60adcec7f20@itomat.se> Date: Mon, 28 Oct 2019 22:30:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Envelope-From: Subject: Re: [PHP-DEV] symbolic links and opcache peculiarity From: eric@persson.tm (Eric Krona) On 2019-10-24 02:03, Helmut K. C. Tessarek wrote: > I'm not sure, if this is a bug or a peculiarity with opcache, but it's > definitely not a user question thus I am poating it in internals. > > I came across a weird situation today that left me dumbfounded. > > I have the following symbolic link: > > index.php -> ../v1/idx.php > > The link index.php is in the directory /data/pr/test/, yet the file > /data/pr/test/index.php was not in the list of cached files even though I > certainly accessed the file and there's no blacklist and other files > in that > directory were in the list. This was the first strange thing, but I > thought, > hey, maybe only the real file (/data/pr/v1/idx.php) is cached. > > But here's the kicker: > > After I changed the sym link to point to another file > index.php -> ../v2/index2.php > I had to reset the opcache that the correct page was served. > > My revalidate_freq is set to 60 seconds. I also tested different browsers, > deleted the cache in the browser, waited for more than 60 seconds, nothing > helped. Only resetting the cache solved the issue (I actually > restarted fpm). > > Please let me know, if I should open a bug or if opcache just doesn't work > with symbolic links. This is a long-standing issue with the opcache, its frequently seen when deploying code using a symlink swap as the final step to atomically launch the new code. There are several pieces of information written on it, such as : * https://codeascraft.com/2013/07/01/atomic-deploys-at-etsy/ * https://engineering.facile.it/blog/eng/realpath-cache-is-it-all-php-opcache-s-fault/ * https://hackernoon.com/truly-atomic-deployments-with-nginx-and-php-fpm-aed8a8ac1cd9 I have not seen a bug report somewhere to php, but its possibly a question if it should be considered a bug or not. There are settings to trigger a re-evaluation which the links describe, and its also possible to call opcache_reset() for example. Most writing I've found is rather old, but I assume its not because the problem is not there anymore but rather that people use different means for deployment nowadays(perhaps). :) /eric