Page MenuHomePhabricator

'Unknown error' in LoadBalancer->reportConnectionError() hides a real database problem
Closed, DuplicatePublic

Description

On a freshly installed PostgreSQL wiki I had a problem with the database connection:

## Database settings
$wgDBtype = "postgres";
$wgDBserver = "";
$wgDBname = "clitest01";
$wgDBuser = "wikiuser";
$wgDBpassword = "*passwd*";

Installation went fine but those settings didn't work for some reason (this is another bug).

Wiki reports only:

Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.
(Cannot contact the database server: No database connection)
Backtrace:

#0 w/includes/db/LoadBalancer.php(752): DatabaseBase->reportConnectionError('Unknown error (...')
#1 w/includes/db/LoadBalancer.php(475): LoadBalancer->reportConnectionError()
#2 w/includes/GlobalFunctions.php(3618): LoadBalancer->getConnection(-1, Array, false)
#3 w/includes/page/WikiPage.php(379): wfGetDB(-1)
#4 w/includes/page/WikiPage.php(462): WikiPage->loadPageData()
#5 w/includes/page/WikiPage.php(515): WikiPage->exists()
#6 w/includes/page/WikiPage.php(222): WikiPage->getContentModel()
#7 w/includes/page/WikiPage.php(208): WikiPage->getContentHandler()
#8 w/includes/actions/Action.php(96): WikiPage->getActionOverrides()
#9 w/includes/actions/Action.php(149): Action::factory('view', Object(WikiPage), Object(RequestContext))
#10 w/includes/MediaWiki.php(164): Action::getActionName(Object(RequestContext))
#11 w/includes/MediaWiki.php(533): MediaWiki->getAction()
#12 w/includes/MediaWiki.php(460): MediaWiki->main()
#13 w/index.php(46): MediaWiki->run()
#14 {main}

After commenting out the "ugly hack" in LoadBalancer::reallyOpenConnection() I am getting a real cause for the problem:

(Cannot contact the database server: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/run/postgresql/.s.PGSQL.5432"?)

Backtrace:

#0 w/includes/db/Database.php(822): DatabasePostgres->open('', 'wikiuser', 'minitest', 'clitest01')
#1 w/includes/db/Database.php(919): DatabaseBase->__construct(Array)
#2 w/includes/db/LoadBalancer.php(717): DatabaseBase::factory('postgres', Array)
#3 w/includes/db/LoadBalancer.php(591): LoadBalancer->reallyOpenConnection(Array, false)
#4 w/includes/db/LoadBalancer.php(471): LoadBalancer->openConnection(0, false)
#5 w/includes/GlobalFunctions.php(3618): LoadBalancer->getConnection(-1, Array, false)
#6 w/includes/page/WikiPage.php(379): wfGetDB(-1)
#7 w/includes/page/WikiPage.php(462): WikiPage->loadPageData()
#8 w/includes/page/WikiPage.php(515): WikiPage->exists()
#9 w/includes/page/WikiPage.php(222): WikiPage->getContentModel()
#10 w/includes/page/WikiPage.php(208): WikiPage->getContentHandler()
#11 w/includes/actions/Action.php(96): WikiPage->getActionOverrides()
#12 w/includes/actions/Action.php(149): Action::factory('view', Object(WikiPage), Object(RequestContext))
#13 w/includes/MediaWiki.php(164): Action::getActionName(Object(RequestContext))
#14 w/includes/MediaWiki.php(533): MediaWiki->getAction()
#15 w/includes/MediaWiki.php(460): MediaWiki->main()
#16 w/index.php(46): MediaWiki->run()
#17 {main}

... which is some pg-specific installer problem we are working on it now.


Version: 1.24rc
Severity: major
See Also: T72225: Freshly installed wiki fails with "Permission denied" on PostgreSQL socket

Details

Reference
bz70223

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:39 AM
bzimport set Reference to bz70223.
bzimport added a subscriber: Unknown Object (MLST).

Change 157488 had a related patch set uploaded by saper:
Do not hide real DB error on first connect

https://gerrit.wikimedia.org/r/157488

The real database problem hidden is actually bug 70225, an instance of a well-known bug 69281.

Change 157488 abandoned by Hashar:
Do not hide real DB error on first connect

Reason:
That would cause T31233 Broken failover for DB slave connection errors.

The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 We have a task for a better fix T35036

https://gerrit.wikimedia.org/r/157488