We are seeing a relatively high number of transients errors with packaging on Drupal.org. A typical session is:

ERROR: /usr/bin/php /var/www/drupal.org/tools/drush5/drush.php --no-cache --include=/var/www/drupal.org/tools/drupalorg_drush make --drupal-org=contrib --drupal-org-build-root=/var/tmp/branch.20167/commerce_kickstart --drupal-org-log-errors-to-file --drupal-org-log-package-metadata=metadata-contrib.json drupal-org.make . failed with status 1

     >> Project omega contains 5 themes: omega, alpha, starterkit_omega_html5, starterkit_omega_xhtml, starterkit_alpha_xhtml.
     >> Project custom_breadcrumbs contains 7 modules: custom_breadcrumbs_taxonomy, custom_breadcrumbsapi, custom_breadcrumbs_panels, custom_breadcrumbs_paths, custom_breadcrumbs_identifiers, custom_breadcrumbs_views, custom_breadcrumbs.
     >> [... a lot of similar success messages ...]

    ERROR: >> Unable to create /tmp/drush_tmp_1339675650_4fd9d402e4f3e.
    ERROR: >> Project cs_adaptive_image (7.x-1.0-alpha2) could not be downloaded to /tmp/make_tmp_1339675649_4fd9d401ded3d/__build__/modules/contrib/cs_adaptive_image.
    ERROR: Build for commerce_kickstart-7.x-2.x-dev-no-core failed.

Looking into it, there is an obvious race condition in drush_mkdir(), which currently read this way:

  if (!is_dir($path)) {
    if (drush_mkdir(dirname($path))) {
      if (@mkdir($path)) {
        return TRUE;
      }
      else {
        // Error.
      }
    }
  }

Drush Make working concurrently, it can happen that a process created the directory while another process was between !is_dir() and @mkdir.

I don't know if this is the root cause of our troubles, but it seems important to fix nonetheless.

Comments

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new496 bytes

I applied the following in production on drupal.org.

damien tournoud’s picture

For reference, it doesn't seem that we have seen this issue since the patch was applied.

moshe weitzman’s picture

Anyone see a problem with this patch?

greg.1.anderson’s picture

It seems okay to me. By inspection, I think that the race condition is eliminated in this patch. The mkdir will not fail unless another process has created the folder, and the subsequent checks should therefore always succeed.

moshe weitzman’s picture

Status: Needs review » Fixed

Committed

Status: Fixed » Closed (fixed)

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