Moodle

postgres native driver, socket connection not working for me

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

The following bit of code, where it tries to use a socket connection if you are on localhost, does not work here on my computer.

Worse, it fails with the generic

Error: Database connection failed

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been
correctly specified in config.php

error, which gives you no clue as to what is actually happening. It took me quite a lot of digging around to acutally get the error message, and find it was coming from around this bit of code, and then try adding 'false and ' to the start of this if statement to make it work again. (Luckily, I knew that you had worked on this over the weekend, so I knew roughly where to look.)

Using sockets seems like a good idea in principle, but it needs to be reliable. Sorry to be the bearer of ill news Petr.

// Unix socket connections should have lower overhead
if (empty($this->dboptions['forcetcp']) and ($this->dbhost === 'localhost' or $this->dbhost === '127.0.0.1')) { $connection = "user='$this->dbuser' password='$pass' dbname='$this->dbname'"; } else {
if (empty($this->dboptions['dbport'])) { $port = 5432; } else { $port = $this->dboptions['dbport']; }
$connection = "host='$this->dbhost' port='$port' user='$this->dbuser' password='$pass' dbname='$this->dbname'";
}

Activity

Hide
Petr Škoda (skodak) added a comment -

fixed

Show
Petr Škoda (skodak) added a comment - fixed
Hide
Tim Hunt added a comment -

Works for me now.

Show
Tim Hunt added a comment - Works for me now.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: