Page MenuHomePhabricator

New install exception is wrong if preflight setup checks fail
Closed, ResolvedPublic

Assigned To
Authored By
dfumagalli
Sep 10 2016, 7:12 PM
Referenced Files
F1813945: 2016-09-13 05_07_01-logged-on.png
Sep 13 2016, 4:33 AM
F1808974: pasted_file
Sep 11 2016, 2:35 AM
F1808747: pasted_file
Sep 11 2016, 1:24 AM
F1808756: pasted_file
Sep 11 2016, 1:24 AM
Tokens
"Mountain of Wealth" token, awarded by dfumagalli.

Description

Reproduction steps:

Exception seen:
Trying to read configuration "phabricator.cache-namespace" before configuration has been initialized.

Versions
Phabricator c0bf08058b77a43a968ea59b8f9c8559d273e758 (git clone has been performed today).
arcanist 9e82ef979e8148c43b9b8439025d505b1219e213 (25 Aug 2016)
libphutil 0107c187b6d8a4c1725972ab80a6cdc97d9912d3 (9 Sep 2016)

Event Timeline

Which versions of php and webserver are you using?

Which versions of php and webserver are you using?

Hello,
In general, it's an Ubuntu 14.04 LTS distribution, along with its default packages.
I have explicitly used the required PHP spawning model (mod-php).

PHP Version 5.5.9-1ubuntu4.19
Linux 3.13.0-45-generic #74-Ubuntu SMP 64 bit (Ubuntu LTS 14.04)
Apache/2.4.7 (Ubuntu)

PHP in this Ubuntu distrubution comes with XCache and I needed to install memcache(d) for another domain. I'll probably see if I can use APCu to make Phabricator happy.

However I feel this is a bug worth mentioning, considering the "You should install APC" message is ready to be output as friendly end user warning (I debugged Phabricator with XDebug so I could read the variables). Moreover, the failover disk based cache has been made.

As "end user" I'd rather be warned by instructions telling me to install APC than getting an error 500 + rather cryptic "Trying to read configuration "phabricator.cache-namespace" before configuration has been initialized."

Yeah, it sounds like some bug, but I can't reproduce it, either with or without APC, and another user complained about it failing with APC installed.

It appears not to be happening on stable, so you can try switching to that while we figure this one out.

I can't reproduce this.

  • I've created a new VM, and installed Ubuntu 14.04.5
  • I've used apt-get install apache2 php5-cli mysql-server git php5-mysql php5-curl
  • I've added apt-get install lamp-server^, for good measure
  • I've configured apache2 as per the instructions, and loaded the page
  • This is what I got:

pasted_file (250×503 px, 17 KB)

  • After running ./bin/storage upgrade and reloading, I got this:

pasted_file (280×433 px, 22 KB)

  • After a couple of false attempts at creating a password, I got to the front page, had 20 pending setup issues, and FireFox crashed.

Php is 5.5.9-1ubuntu4.19, no APC or APCu,
Apache version 2.4.7 (Ubuntu),
Phabricator at the same versions as you specified.

you can't reproduce stable or master? a lot of setup was re-written this week and stable hasn't been cut yet.

On Master. Both this report and the one in IRC were about master.

Also, the one in IRC says he's got this error with APC loaded, with php 5.6.25, and that reverting to stable fixed this for him.

If you cannot reproduce the issue, I can create a video of a XDebug session leading to the error, so you see the program flow.

That might help.
Also, a stack-trace (should be in the webserver error log) might show something.

That might help.
Also, a stack-trace (should be in the webserver error log) might show something.

Since it's 3am here, I am going to create the video tomorrow.

About Apache 2 error logs: I have enabled (added few lines) full PHP debug in the index.php.

Anyway here are the access and then error logs

Access log

83.nn.nn.nn - - [10/Sep/2016:15:45:00 +0000] "GET / HTTP/1.1" 500 368 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0"
83.nn.nn.nn - - [10/Sep/2016:15:45:35 +0000] "GET / HTTP/1.1" 500 368 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0"
83.nn.nn.nn - - [10/Sep/2016:15:49:50 +0000] "GET / HTTP/1.1" 500 1997 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0"
83.nn.nn.nn - - [10/Sep/2016:16:00:30 +0000] "GET / HTTP/1.1" 500 1997 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0"

Error log

[Sat Sep 10 21:47:29.505548 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP Warning:  array_key_exists() expects parameter 2 to be array, null given in /var/www/anonymized_path/phabricator/src/infrastructure/env/PhabricatorEnv.php on line 322
[Sat Sep 10 21:47:29.505622 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP Stack trace:
[Sat Sep 10 21:47:29.505663 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   1. {main}() /var/www/anonymized_path/phabricator/webroot/index.php:0
[Sat Sep 10 21:47:29.505710 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   2. AphrontApplicationConfiguration::runHTTPRequest() /var/www/anonymized_path/phabricator/webroot/index.php:21
[Sat Sep 10 21:47:29.505758 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   3. AphrontApplicationConfiguration::writeResponse() /var/www/anonymized_path/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:76
[Sat Sep 10 21:47:29.505806 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   4. AphrontHTTPSink->writeResponse() /var/www/anonymized_path/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:309
[Sat Sep 10 21:47:29.505855 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   5. AphrontResponse->getContentIterator() /var/www/anonymized_path/phabricator/src/aphront/sink/AphrontHTTPSink.php:102
[Sat Sep 10 21:47:29.505896 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   6. AphrontStandaloneHTMLResponse->buildResponseString() /var/www/anonymized_path/phabricator/src/aphront/response/AphrontResponse.php:27
[Sat Sep 10 21:47:29.505943 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   7. PhabricatorConfigResponse->getResponseBodyClass() /var/www/anonymized_path/phabricator/src/aphront/response/AphrontStandaloneHTMLResponse.php:20
[Sat Sep 10 21:47:29.505983 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   8. PhabricatorSetupCheck::isInFlight() /var/www/anonymized_path/phabricator/src/applications/config/response/PhabricatorConfigResponse.php:28
[Sat Sep 10 21:47:29.506020 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP   9. PhabricatorSetupCheck::getOpenSetupIssueKeys() /var/www/anonymized_path/phabricator/src/applications/config/check/PhabricatorSetupCheck.php:207
[Sat Sep 10 21:47:29.506074 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP  10. PhabricatorCaches::getSetupCache() /var/www/anonymized_path/phabricator/src/applications/config/check/PhabricatorSetupCheck.php:67
[Sat Sep 10 21:47:29.506125 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP  11. PhabricatorCaches::newStackFromCaches() /var/www/anonymized_path/phabricator/src/applications/cache/PhabricatorCaches.php:167
[Sat Sep 10 21:47:29.506270 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010
] PHP  12. PhabricatorCaches::addNamespaceToCaches() /var/www/anonymized_path/phabricator/src/applications/cache/PhabricatorCaches.php:19
[Sat Sep 10 21:47:29.506316 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010
] PHP  13. PhabricatorCaches::getNamespace() /var/www/anonymized_path/p
habricator/src/applications/cache/PhabricatorCaches.php:285
[Sat Sep 10 21:47:29.506365 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP  14. PhabricatorEnv::getEnvConfig() /var/www/anonymized_path/phabricator/src/applications/cache/PhabricatorCaches.php:15
[Sat Sep 10 21:47:29.506417 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] PHP  15. array_key_exists() /var/www/anonymized_path/phabricator/src/infrastructure/env/PhabricatorEnv.php:322
[Sat Sep 10 21:47:29.510044 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] [2016-09-10 21:47:29] EXCEPTION: (Exception) Trying to read configuration "phabricator.cache-namespace" before configuration has been initialized. at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:327]
[Sat Sep 10 21:47:29.518675 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010] arcanist(head=master, ref.master=9e82ef979e81), phabricator(head=master, ref.master=c0bf08058b77), phutil(head=master, ref.master=0107c187b6d8)
[Sat Sep 10 21:47:29.518740 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #0 <#2> PhabricatorEnv::getEnvConfig(string) called at [<phabricator>/src/applications/cache/PhabricatorCaches.php:15]
[Sat Sep 10 21:47:29.518769 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #1 <#2> PhabricatorCaches::getNamespace() called at [<phabricator>/src/applications/cache/PhabricatorCaches.php:285]
[Sat Sep 10 21:47:29.518806 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #2 <#2> PhabricatorCaches::addNamespaceToCaches(array) called at [<phabricator>/src/applications/cache/PhabricatorCaches.php:19]
[Sat Sep 10 21:47:29.518850 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #3 <#2> PhabricatorCaches::newStackFromCaches(array) called at [<phabricator>/src/applications/cache/PhabricatorCaches.php:167]
[Sat Sep 10 21:47:29.518902 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #4 <#2> PhabricatorCaches::getSetupCache() called at [<phabricator>/src/applications/config/check/PhabricatorSetupCheck.php:67]
[Sat Sep 10 21:47:29.518954 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #5 <#2> PhabricatorSetupCheck::getOpenSetupIssueKeys() called at [<phabricator>/src/applications/config/check/PhabricatorSetupCheck.php:207]
[Sat Sep 10 21:47:29.518998 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #6 <#2> PhabricatorSetupCheck::isInFlight() called at [<phabricator>/src/applications/config/response/PhabricatorConfigResponse.php:28]
[Sat Sep 10 21:47:29.519050 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #7 <#2> PhabricatorConfigResponse::getResponseBodyClass() called at [<phabricator>/src/aphront/response/AphrontStandaloneHTMLResponse.php:20]
[Sat Sep 10 21:47:29.519086 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #8 <#2> AphrontStandaloneHTMLResponse::buildResponseString() called at [<phabricator>/src/aphront/response/AphrontResponse.php:27]
[Sat Sep 10 21:47:29.519124 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #9 <#2> AphrontResponse::getContentIterator() called at [<phabricator>/src/aphront/sink/AphrontHTTPSink.php:102]
[Sat Sep 10 21:47:29.519168 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #10 <#2> AphrontHTTPSink::writeResponse(PhabricatorConfigResponse) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:309]
[Sat Sep 10 21:47:29.519213 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #11 <#2> AphrontApplicationConfiguration::writeResponse(AphrontPHPHTTPSink, PhabricatorConfigResponse) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:76]
[Sat Sep 10 21:47:29.519331 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #12 <#2> AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:21]
[Sat Sep 10 21:47:29.519376 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #13 phlog(Exception) called at [<phabricator>/src/aphront/response/AphrontUnhandledExceptionResponse.php:20]
[Sat Sep 10 21:47:29.519420 2016] [:error] [pid 10140] [client 83.nn.nn.nn:52010]   #14 AphrontUnhandledExceptionResponse::setException(Exception) called at [<phabricator>/webroot/index.php:25]

I repro it fine.

Ubuntu 14.04
apt-get install php5 mysql-server apache2

PHP 5.5.9-1ubuntu4.19 (cli) (built: Jul 28 2016 19:31:33) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
root@ubuntu:/var/www/html/dev# php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

pasted_file (437×1 px, 131 KB)

yeah, I've removed php-mysql and then I get the same error.

oh good, I was in the middle of figuring that out next. I tried installing APC and APCu but still got the error.

chad renamed this task from Setup fails to fall back to disk cache to Setup fails oddly is php-mysql is not installed.Sep 11 2016, 2:42 AM
chad renamed this task from Setup fails oddly is php-mysql is not installed to Setup fails oddly if php-mysql is not installed.
chad renamed this task from Setup fails oddly if php-mysql is not installed to Setup fails oddly if php5-mysql is not installed.

Verified, removing php5-mysql reproduces the error.

_ _ __ ___ ___)_ _____ _ _ _ __ _ _| | ___ ___ / _` \ \ / / \ \ / / _ \ | | | | '__| | | | |/ _ \ __| | (_| |\ V /| |\ V / __/ |_| | | | | |_| | | __\__ \ \__,_| \_/ |_| \_/ \___|\__, | |_| \__,_|_|\___|___/ |___/
chad renamed this task from Setup fails oddly if php5-mysql is not installed to New install exception is wrong if extension setup checks fail.Sep 11 2016, 2:52 AM

maybe that is better?

Yeah, I think that's extensive enough. And I think that's the only check right now that might blow up, but I didn't follow the recent changes.

Hello,

Here are my own PHP modules:

php -m

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
intl
json
libxml
mbstring
mcrypt
memcache
memcached
mhash
ming
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
pspell
readline
recode
Reflection
session
shmop
SimpleXML
snmp
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
XCache
XCache Cacher
XCache Coverager
XCache Optimizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
XCache
XCache Cacher
XCache Coverager
XCache Optimizer
Xdebug
Zend OPcache

I have mySQL installed, the server actually needs it because it's running ISPConfig 3 and manages a few other subdomains with other development web applications.

Anyway do you still need the video, or did you find the affected code?

We found what we think is a repro case, but we don't know if it's the same as your repro case. Only you could tell us that, but I don't think a video would be useful.

These are the modules from our Ubuntu script that we install by default:
apt-get install php5 php5-mysql php5-gd php5-dev php5-curl php-apc php5-cli php5-json

It looks like you have all the required extensions, although it's possible that they are only enabled when running php from the command line, and not from Apache; If you can get a php page to run phpinfo(), it will print out the full information from the right context.

Alternatively, if you checkout stable branch of Phabricator, you'll get a better error message.

I am able to reproduce this using another class of errors from https://secure.phabricator.com/diffusion/P/browse/master/src/applications/config/check/PhabricatorPHPPreflightSetupCheck.php, but these are all much more complex to explain.

In any case, I don't think we need the video, thanks.

avivey renamed this task from New install exception is wrong if extension setup checks fail to New install exception is wrong if preflight setup checks fail.Sep 11 2016, 5:37 PM
avivey updated the task description. (Show Details)

It looks like you have all the required extensions, although it's possible that they are only enabled when running php from the command line, and not from Apache; If you can get a php page to run phpinfo(), it will print out the full information from the right context.

Alternatively, if you checkout stable branch of Phabricator, you'll get a better error message.

I am able to reproduce this using another class of errors from https://secure.phabricator.com/diffusion/P/browse/master/src/applications/config/check/PhabricatorPHPPreflightSetupCheck.php, but these are all much more complex to explain.

In any case, I don't think we need the video, thanks.

I have installed APCu, which on Ubuntu causes automatic uninstall of xcache.
Made sure to enable it in: /etc/php5/mods-available/apcu.ini:

extension=apcu.so
apc.enabled=1
apc.enable_cli=1

Restarted everything, APCu appears on phpinfo() output, with the given settings.

However, I still get: "Trying to read configuration "phabricator.cache-namespace" before configuration has been initialized." when opening Phabricator home page (which should trigger setup instead).

I have double checked, I have all the php packages indicated in this post.

Are you running apparmor or selinux?

In T11613#194219, @chad wrote:

Are you running apparmor or selinux?

apparmor_status
apparmor module is loaded.
9 profiles are loaded.
9 profiles are in enforce mode.
   /sbin/dhclient
   /usr/bin/freshclam
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/lib/connman/scripts/dhclient-script
   /usr/sbin/clamd
   /usr/sbin/mysqld
   /usr/sbin/named
   /usr/sbin/ntpd
   /usr/sbin/tcpdump
0 profiles are in complain mode.
5 processes have profiles defined.
5 processes are in enforce mode.
   /usr/bin/freshclam (2071)
   /usr/sbin/clamd (1920)
   /usr/sbin/mysqld (1164)
   /usr/sbin/named (1184)
   /usr/sbin/ntpd (1952)
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.

Edit: I have stopped the apparmor service, but the exception still gets thrown.

epriestley triaged this task as Normal priority.

D16542 should fix this and reveal whatever the underlying error is.

After fixing a bug in the provided .htaccess (recursion because of using "L" flag in self-modifying path), setup starts. However by quickly assessing the PHP code, I have noticed how APC "auto-detect" is PHP < 5.5 oriented.

Most professional VPS / dedicated servers are going to use 5.5 and above, where APCu and not APC is the package to install.

Therefore, I suggest changing the detection code from checking for "apc" exact match to a "apcu?" regex.

Did you pull the latest code down? What is the error you are seeing now?

we detect and work correctly with both apc and apcu; Specifically, apcu pretends to be apc in many contexts, and we have code to distinguish them when needed.

After fixing a bug in the provided .htaccess (recursion because of using "L" flag in self-modifying path), setup starts.

Are you following another guide on the internet? We don't provide .htaccess configurations in our guides.

In T11613#194386, @chad wrote:

After fixing a bug in the provided .htaccess (recursion because of using "L" flag in self-modifying path), setup starts.

Are you following another guide on the internet? We don't provide .htaccess configurations in our guides.

Please excuse me, I did not want to mention ".htaccess" but the Apache conf listed here.

Can you file a bug report then if you believe the documentation contains a bug?

In T11613#194389, @chad wrote:

Can you file a bug report then if you believe the documentation contains a bug?

Sure, right after I am done filing another bug about another issue with the guided setup.

Assuming probably you're seeing T10352

In T11613#194396, @chad wrote:

Assuming probably you're seeing T10352

Yes, I have read that. Putting "END" solves the recursion but the issue about path being empty comes up as in that bug report.
Since the suggested diagnostic PHP snippet shows path being correctly handled by "END" (except for when we call the website root), a quick'n' dirty fix I have tried is to look at the code checking path <> "" and set path = '/' if empty instead of raising an exception.

In T11613#194396, @chad wrote:

Assuming probably you're seeing T10352

Yes, I have read that. Putting "END" solves the recursion but the issue about path being empty comes up as in that bug report.
Since the suggested diagnostic PHP snippet shows path being correctly handled by "END" (except for when we call the website root), a quick'n' dirty fix I have tried is to look at the code checking path <> "" and set path = '/' if empty instead of raising an exception.

Here's an .htaccess file I have created, for those who cannot / don't want to edit the vhost configuration file or for those who just cannot get the suggested vhost configuration working.

This .htaccess is provided as is and works on the Ubuntu 14.04 LTS distribution I have described in the first posts + ISPConfig 3.05 "control panel". The file is meant to be put inside the {INSTALL ROOT}/phabricator/webroot directory.

This file has fixed every issue I had, including what's quoted above and also including endless self-recursion indicated by old ticket T10301.

We had two kinds of recursions:

  • Apache internal redirect, halting after 10 loops. Depending on web server version and configuration, this recursion caused by the "L" clause at the end of the 3rd rewrite rule, which is modifying the URL in a way that triggers more rewrites on itself.

The full explanation is given by the immensely valuable rewrite rules URL suggested by another Developer some posts above. In particular, the issue affecting some Apache configurations is the one listed at: "Common pitfalls", under: "3. [L] is not last! (sometimes)".

  • Using END in place of L, fixes the above but I also had another issue: the leading "/" in the path would get stripped off, causing an exception (path empty). Even forcing the code to work, AphrontRoutingMap->tryRoute($route, $value, $path) would fail to match any controller path. I added a "/" in the .htaccess file in front of $1 at the end of the last rewrite. This made everything snap in and work, as the screenshot proves.

2016-09-13 05_07_01-logged-on.png (439×987 px, 26 KB)

Therefore, anyone with a server configuration similar to mine and trying to use my .htaccess: first try it as-is, if you see it does not work, try removing the "/" in front of the $1 at the end of the last rewrite.

.htaccess contents:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^/rsrc/(.*) - [L,QSA]
  RewriteRule ^/favicon.ico - [L,QSA]
  RewriteRule ^(.*)$ /index.php?__path__=/$1 [B,END,QSA]
</IfModule>

Since I have no further issue using Phabricator, and considering I am already enjoying the utter awesomeness of this piece of software, I consider this ticket solved.