Skip to content

[FrameworkBundle] prevent cache:clear creating too long paths #16829

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

Merged
merged 1 commit into from
Dec 10, 2015

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Dec 4, 2015

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #15547 #16783
License MIT
Doc PR -

$kernel = $this->getContainer()->get('kernel');
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);

if ($input->getOption('no-warmup')) {
$filesystem->rename($realCacheDir, $oldCacheDir);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was really dumb. it renamed the folder, just to remove it then.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the purpose of that to provide a clean cache dir faster? Since renaming takes less time than removing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have some evidence for this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obviously heavily platform dependent, so its difficult to provide good evidence.
As a comparison on a high / low resource system: (Cache size: 11.2MB, 772 files, 512 directories)

50 iterations Rename Remove
high ~3ms ~687ms
low ~4ms ~3708ms

https://gist.github.com/Tischoi/2dc5c0ef3bfa08328478

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd the purpose of this line is to have an atomic clearing of the cache. If I'm not wrong, we should keep it (and add a comment about it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on the filesystem you use. Normally removing a directory only involves removing a reference it to. Also I don't think it matters at the end and I could not find any information that this was done on purpose in git.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll revert that. From what I read, moving a directory is more likely to be atomic than deleting. Most filesystems implement moving a directory on the same partition atomically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

@@ -100,8 +102,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true)
{
$this->getContainer()->get('filesystem')->remove($warmupDir);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was done twice

@Tobion
Copy link
Contributor Author

Tobion commented Dec 7, 2015

ping @symfony/deciders this fix is important to merge as the bug is currently causing problems for all windows users running symfony. Together with doctrine/cache#107 it is gone.

@fabpot
Copy link
Member

fabpot commented Dec 7, 2015

👍

@xabbuh
Copy link
Member

xabbuh commented Dec 7, 2015

👍

Status: Reviewed

@Tobion Tobion merged commit 6e279c5 into symfony:2.3 Dec 10, 2015
Tobion added a commit that referenced this pull request Dec 10, 2015
…ths (Tobion)

This PR was merged into the 2.3 branch.

Discussion
----------

[FrameworkBundle] prevent cache:clear creating too long paths

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15547 #16783
| License       | MIT
| Doc PR        | -

Commits
-------

6e279c5 [FrameworkBundle] prevent cache:clear creating too long paths
@Tobion Tobion deleted the warmup-max-path branch December 10, 2015 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants