I am testing out upgrading devshop to the next release, which switches over to hosting_git for git URL and git_ref storage.

I am unable to run hostmaster-migrate because updb fails, because the code that loads the nodes for projects and environments looks for the hosting_git table. The nodes are being loaded after the update list is displayed, but before the updates take place.

Luckily I had xdebug installed and I could trace it back to this:


/**
 * @file
 * Drush include for the Hosting module.
 */

define('HOSTING_QUEUE_DEFAULT_LOCK_WAIT', 30);
define('HOSTING_QUEUE_LOCK_TIMEOUT', 3600.0);

/**
 * Implements hook_drush_command().
 */
function hosting_drush_command() {
  $items['hosting-dispatch'] = array(
    'description' => dt('Centralized command for dispatching the various queue processors (hosting, cron, backup etc.)'),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => array(
      'lock-wait' => dt('Time to wait to acquire a lock on dispatched queues. Defaults to @wait seconds.', array('@wait' => HOSTING_QUEUE_DEFAULT_LOCK_WAIT)),
      'force' => dt('Continue even if the task queue is still locked.'),
    ),
  );

  $items['hosting-setup'] = array(
    'description' => dt('Set up initial configuration settings such as the cron entry for the queue dispatcher and more.'),
  );

  // If we're trying to get help, then try to bootstrap as much as possible.
  $current_command = drush_get_command();
  if (isset($current_command['command']) && ($current_command['command'] == 'help')) {
    drush_bootstrap_max();
  }

  // If we've not bootstrapped fully, then this function may not be around.
  if (function_exists('hosting_get_queues')) {
    $queues = hosting_get_queues();


 ...

As you can see at the end, hosting_get_queues() is called, which does a few things.

This is done inside the function hosting_drush_command() which is for hook_drush_command(), which is for defining what commands are available.

This is so we can dynamically create drush commands based on the hosting queue meta data:

drush hosting-$queue
drush hosting-tasks
drush hosting-cron

The problem is that hook_hosting_queues() implementations use dynamic lookups for the "total_items" property, when this hook should be metadata only.

So, on hostmaster-migrate, the new platform is verified, and it attempts the update_db, then immediately fails when it tries to lookup the nodes with the table that doesn't exist yet.

I can read from the stack trace, that drush_core_updatedb() eventually calls drush_get_commands() which calls hosting_drush_command() which calls hosting_get_queues() which calls my devshop queue which tries to load nodes using hosting_git, which doesn't exist until the database updates occur.

:O

I would rather not check for hosting_git before doing my hook_entity_load() code, but I guess I might not have a choice!

Comments

Jon Pugh created an issue. See original summary.

Jon Pugh’s picture

Issue summary: View changes
Jon Pugh’s picture

Issue summary: View changes
Jon Pugh’s picture

Title: hosting_get_queues() shouldn't load dynamic data and also be invoked in hook_drush_command() » Upgrades with schema changes for nodes will break for hostmaster upgrades because hosting_get_queues() is invoked before updb
helmo’s picture

Can't we exit early from hosting_drush_command() in this condition?

I assume that we have no need for these queue commands during the hosting-migrate execution... The trick will be to find the best indicator.

Jon Pugh’s picture

Version: 7.x-3.8 » 7.x-3.x-dev
Priority: Major » Critical
Status: Active » Needs work

This is rearing it's ugly head again: the files_public_path field is being added in the patch over at #3016995: Make file directories first class context properties.

See https://travis-ci.org/opendevshop/devmaster/jobs/596765778#L5011