Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpKernel] [Profiler] High concurrency access to mkdir($this->folder) leads to warning in FileProfilerStorage #16258

Closed
@abienvenu

Description

@abienvenu

I sometimes get this warning :

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Warning: mkdir(): File exists" at [...]/symfony/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php line 45 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Warning: mkdir(): File exists at [...]/symfony/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php:45)"} []

This happens when calling multiple Symfony web pages at the same time, while Symfony just had its cache cleared.
Actually this code is not atomic :

        if (!is_dir($this->folder)) {
            mkdir($this->folder, 0777, true);
        }

Nothing prevents the directory from being created twice.

It is not a big issue, since the error will happen only if profiler is enabled, and at most once after each cache:clear.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions