Problem/Motivation

After upgrade debian package 3.186 -> 3.190 when you try to delete a site it fails.

The drush version before upgrade was 8.1.16 and after upgrade was the same. I tested upgrading to drush 8.4.5 but the same happens.

Steps to reproduce

In 3.186 without extra modules activated, create and delete a site to verify everything is working.
Upgrade to 3.190. (note some warnings occur now when verifying platforms)
Create a site.
Disable an delete the site.
You get 3 warning and 1 error:

Warning: File path "/var/aegir/platforms/d776dev/" was not deleted, because it may contain files from other sites. You must manually delete the folder. - warning
Warning: File path "/var/aegir/platforms/d776dev/" was not deleted, because it may contain files from other sites. You must manually delete the folder. - warning
Warning: File path "/var/aegir/platforms/d776dev/" was not deleted, because it may contain files from other sites. You must manually delete the folder. - warning
...
The external command could not be executed due to an application error. - error

screenshot

NOTE: if now you delete the platform then you can successfully delete your site.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

solanas created an issue. See original summary.

helmo’s picture

Status: Active » Needs review

This is fixed in the 3.19.1 release which we currently have in our testing repo.

You can try the upgrade using the deb source deb [signed-by=/usr/share/keyrings/aegir-archive-keyring.gpg] https://debian.aegirproject.org testing main.

solanas’s picture

FileSize
73.95 KB

Thank you Helmo.

Upgraded from 3.186 -> 3.191 (testing debian) SOLVES the problem and the site is deleted but the task finish with warning.

I attach the screen I get.

screenshot

helmo’s picture

Status: Needs review » Fixed
solanas’s picture

Status: Fixed » Needs work
FileSize
16.53 KB

I reopen this issue because now with 3.192 (debian testing) deleting sites is failing.

If I have Drush 8.4.5 I get:

screenshot

When deleted with drush command (drush @d8site provision-delete) I get this error:

...
...
Platforms path /var/aegir/platforms is writable.                                                                                     [success]
Failed to log error: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd8site.cache_bootstrap' doesn't exist: INSERT INTO {cache_bootstrap} (cid, expire, created, tags, checksum, data, serialized) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6) ON DUPLICATE KEY UPDATE cid = VALUES(cid), expire = VALUES(expire), created = VALUES(created), tags = VALUES(tags), checksum = VALUES(checksum), data = VALUES(data), serialized = VALUES(serialized); Array
...
...
 in Drupal\Core\Extension\ModuleHandler->writeCache() (line 337 of /var/aegir/platforms/d8910dev/web/core/lib/Drupal/Core/Extension/ModuleHandler.php). #0 /var/aegir/platforms/d8910dev/web/core/lib/Drupal/Core/Database/Connection.php(665): Drupal\Core\Database\Connection->handleQueryException(Object(PDOException), 'INSERT INTO {ca...', Array, Array)
...
...

If i restore to drush 8.1.16 it's deleted with no erros.

Not sure if this need more testing as It seems drush 8.4.5 should be required in order to deploy drupal 9 sites.

solanas’s picture

Testing this another time. Upgrading to drush 8.4.5, if after the failed delete task I run it by twice the task finish succesfully.

gval’s picture

I have the same problem with the delete task. Tested on an "old" cloned site; the task failed after removing the site database.
If I run the delete task again, it completes successfully. I also did another test: if I create a new site on the same platform and delete it, the delete task completes successfully on the first attempt.

Don't know what are the differences between these 2 sites that triggering or not the error. (drush context ? / alias ?...)

My error log here (Drush 8.4.6 - provision 3.186) :

[...]
-> Dropping database tableurtest123_0	

-> PDOException in database_exists	

-> notice SQLSTATE[HY000] [1049] Unknown database 'tableurtest123_0'	

-> PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'tableurtest123_0.locales_source' doesn't exist in /data/disk/prod1/static/d7.77.1-c5.30.1-d2/includes/database/database.inc:2256
Stack trace:
#0 /data/disk/prod1/static/d7.77.1-c5.30.1-d2/includes/database/database.inc(2256): PDOStatement->execute(Array)
#1 /data/disk/prod1/static/d7.77.1-c5.30.1-d2/includes/database/database.inc(724): DatabaseStatementBase->execute(Array, Array)
#2 /data/disk/prod1/static/d7.77.1-c5.30.1-d2/includes/database/database.inc(2435): DatabaseConnection->query('SELECT s.lid, t...', Array, Array)
#3 /data/disk/prod1/static/d7.77.1-c5.30.1-d2/modules/locale/locale.module(720): db_query('SELECT s.lid, t...', Array)
#4 /data/disk/prod1/static/d7.77.1-c5.30.1-d2/includes/bootstrap.inc(1775): locale('Revoking privil...', '', 'fr')
#5 /data/disk/prod1/tools/drush/includes/output.inc(154): t('Revoking privil...', Array)
#6 /data/disk/prod1/.drush/sys/provision/db/Provision/Service/db.php(165): dt('Revoking privil...', Array)
#7 /data/disk/prod1/.drush/sys/provision/db/delete.provision.inc(16): Provision_Service_db->destroy_site_database()
#8 /data/disk/prod1/tools/drush/includes/command.inc(422): drush_db_provision_delete()
#9 /data/disk/prod1/tools/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#10 /data/disk/prod1/tools/drush/includes/command.inc(199): drush_command()
#11 /data/disk/prod1/tools/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#12 /data/disk/prod1/tools/drush/includes/preflight.inc(67): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#13 /data/disk/prod1/tools/drush/drush.php(12): drush_main()
#14 {main}
lexbritvin’s picture

I had the same issue as @gval

I debugged the issue and found the root cause.

The issue comes from high bootstrap level and using of dt() function for logging. It tries to get translation from the deleted database.

The changed function that produces the error is:

function drush_provision_drupal_pre_provision_delete($backup_file = NULL) {
  if (d()->type === 'site') {
    drush_set_option('force', true, 'process');
    if (!empty($backup_file) && !strpos($backup_file, '/')) {
      drush_set_error('PROVISION_DELETE_BACKUP_NAME_RELATIVE', dt('The passed backup name is a relative path, storing that in the site directory which is going to be deleted is probably not intended. Try an absolute name, or no name to let one be generated.'));
    }
    // If site database exists and is boostrapped, run a backup.
    elseif (drush_bootstrap_max() == DRUSH_BOOTSTRAP_DRUPAL_LOGIN) {
      drush_log(dt('Invoking drush provision-backup...'));
      drush_invoke("provision-backup", $backup_file);
      drush_unset_option('force', 'process');
    }
    else {
      drush_log(dt('Warning: A site backup was not made because a site database was not found.'), 'warning');
    }
  }
}

As you can see, it tries to increase level to maximum by drush_bootstrap_max(). It fixes the error when a database is missing but produces an error when deleting a working site.

So I patched it and reverted to the previous version. See the patch attached.
It may be not the best solution but I value site deletion more than missing database which is an exceptional case that I can fix manually.

The issue still needs work to support both features but checking the existing database must be done without increasing the bootstrap level.

colan’s picture

Status: Needs work » Needs review
sseidel’s picture

We have the same problem. We found out that for us it happens when the site default language is changed. This is a major bug I think because it breaks drush commands by modifying a site - a user can change the default language of a site and thereby break the underlying management system, that's not good.

I will test the patch and see if it resolves the issue for us.

doka’s picture

Patch #8 works for me, on 3.192.

sseidel’s picture

The patch also works for us, so it would be great if it could be incorporated into a new release. Because this problem leaves behind a lot of sites that are hard to delete because the database doesn't exist anymore.

colan’s picture

Status: Needs review » Reviewed & tested by the community

  • kienan committed f36f4e3 on 7.x-3.x authored by lexbritvin
    Issue #3187556 by lexbritvin, solanas, sseidel, doka: Error deleting a...
kienan’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.