As it's currently written, there's a race condition in _less_pre_render() in the event of high concurrency.

If you flush the cache, and the site is simultaneously serving a large number of pages, some of those pages will get no styles, and you'll see log messages like

LESS could not create a directory in public://less/5139043775cd21.37298789/sites/all/themes/themename/css

This appears to be because the process of creating the deep directory structure can take a few ms, and if two start doing it at once there can be issues.

I'm seeing this in part because our system uses network-attached storage which stretches out the time to create the directories in such a way that this happens a non-trivial number of times.

Alternative patterns might be:

  • writing to a single file with a unique name
  • adding some kind of locking while generating the aggregate (ala image_style_deliver())
  • adding a retry

I'd argue in favor of using single files rather than a directory tree as it makes cleaning up a lot easier too.

I'm not sure how much this use-case matters to you, but if you're open to this proposal I can roll a patch.

Comments

corey.aufang’s picture

I'd much rather have it locks or retries rather than a unique file name.

Currently the pathing system in use is so that developers can find where the original .less files are very simply. The module used to use a filename that had a MD5 of the files contents as the base name, but that led to too much confusion.

If you would like to create a patch, can you try rolling it against the 7.x-3.x version? That will be the next generation and I hope that 7.x-2.6 will be the last 7.x-2.x release.

corey.aufang’s picture

Version: 7.x-2.6 » 7.x-3.x-dev
Status: Active » Needs review

I've made a commit that should deal with the concurrency issue.

Please check out the latest 7.x-3.x-dev build and let me know if this fixes the situation that you were running into.

Again, there will be no further updates to the 7.x-2.x branch.

corey.aufang’s picture

Status: Needs review » Fixed

This should be resolved in 7.x-3.0.

Status: Fixed » Closed (fixed)

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

  • Commit f2dc322 on 7.x-3.x, 7.x-4.x by corey.aufang:
    Issue #1936896 by corey.aufang: Adding locks on directory creation to...