Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round 2 for Drupal transaction isolation, fixes #4281 #4351

Merged
merged 3 commits into from Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 22 additions & 9 deletions pkg/ddevapp/drupal.go
Expand Up @@ -382,15 +382,28 @@ func drupal8PostStartAction(app *DdevApp) error {
}

func drupalPostStartAction(app *DdevApp) error {
// pg_trm extension is required
if app.Database.Type == nodeps.Postgres && (isDrupal9App(app) || isDrupal10App(app)) {
stdout, stderr, err := app.Exec(&ExecOpts{
Service: "db",
Cmd: `psql -q -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" 2>/dev/null`,
NoCapture: false,
})
if err != nil {
util.Warning("unable to CREATE EXTENSION pg_trm: stdout='%s', stderr='%s', err=%v", stdout, stderr, err)
if isDrupal9App(app) || isDrupal10App(app) {
// pg_trm extension is required in Drupal9.5+
if app.Database.Type == nodeps.Postgres {
stdout, stderr, err := app.Exec(&ExecOpts{
Service: "db",
Cmd: `psql -q -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" 2>/dev/null`,
NoCapture: false,
})
if err != nil {
util.Warning("unable to CREATE EXTENSION pg_trm: stdout='%s', stderr='%s', err=%v", stdout, stderr, err)
}
}
// SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED required in Drupal 9.5+
if app.Database.Type == nodeps.MariaDB || app.Database.Type == nodeps.MySQL {
stdout, stderr, err := app.Exec(&ExecOpts{
Service: "db",
Cmd: `mysql -e "SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;" 2>/dev/null`,
NoCapture: false,
})
if err != nil {
util.Warning("unable to SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED: stdout='%s', stderr='%s', err=%v", stdout, stderr, err)
}
}
}
// Return early because we aren't expected to manage settings.
Expand Down
7 changes: 0 additions & 7 deletions pkg/ddevapp/drupal/drupal10/settings.ddev.php
Expand Up @@ -28,13 +28,6 @@
'prefix' => "{{ $config.DatabasePrefix }}",
);


// Setting the MySQL transaction isolation level.
// @see https://www.drupal.org/docs/system-requirements/setting-the-mysql-transaction-isolation-level
if ($driver === "mysql") {
$databases['default']['default']['init_commands']['isolation_level'] = 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED';
}

$settings['hash_salt'] = '{{ $config.HashSalt }}';

// This will prevent Drupal from setting read-only permissions on sites/default.
Expand Down
7 changes: 0 additions & 7 deletions pkg/ddevapp/drupal/drupal9/settings.ddev.php
Expand Up @@ -28,13 +28,6 @@
'prefix' => "{{ $config.DatabasePrefix }}",
);


// Setting the MySQL transaction isolation level.
// @see https://www.drupal.org/docs/system-requirements/setting-the-mysql-transaction-isolation-level
if ($driver === "mysql") {
$databases['default']['default']['init_commands']['isolation_level'] = 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED';
}

$settings['hash_salt'] = '{{ $config.HashSalt }}';

// This will prevent Drupal from setting read-only permissions on sites/default.
Expand Down