Skip to content
Snippets Groups Projects
Commit 74b996ce authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2751537 by chx: Race condition in...

Issue #2751537 by chx: Race condition in \Drupal\Core\Database\Driver\pgsql\Install\Tasks breaks the testbot
parent 871da5e4
No related branches found
No related tags found
No related merge requests found
......@@ -246,6 +246,9 @@ function initializeDatabase() {
// concurrency issues, when both try to update at the same time.
try {
$connection = Database::getConnection();
// When testing, two installs might try to run the CREATE FUNCTION queries
// at the same time. Do not let that happen.
$connection->query('SELECT pg_advisory_lock(1)');
// Don't use {} around pg_proc table.
if (!$connection->query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'")->fetchField()) {
$connection->query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS
......@@ -264,6 +267,7 @@ function initializeDatabase() {
[ 'allow_delimiter_in_query' => TRUE ]
);
}
$connection->query('SELECT pg_advisory_unlock(1)');
$this->pass(t('PostgreSQL has initialized itself.'));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment