Skip to content
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

Web Profiler inconsistent error - Undefined array key 4 #50942

Closed
radar3301 opened this issue Jul 11, 2023 · 4 comments
Closed

Web Profiler inconsistent error - Undefined array key 4 #50942

radar3301 opened this issue Jul 11, 2023 · 4 comments

Comments

@radar3301
Copy link
Contributor

radar3301 commented Jul 11, 2023

Symfony version(s) affected

6.3.1

Description

Very occassionally, when navigating '/logout' (302 redirect) '/' (302 redirect) '/login, I get the following errors:

ErrorException:
Warning: Undefined array key 4

  at symfony\http-kernel\Profiler\FileProfilerStorage.php:312
  at Symfony\Component\HttpKernel\Profiler\FileProfilerStorage->removeExpiredProfiles()
  at Symfony\Component\HttpKernel\Profiler\FileProfilerStorage->write()
  at Symfony\Component\HttpKernel\Profiler\Profiler->saveProfile()
  at Symfony\Component\HttpKernel\EventListener\ProfilerListener->onKernelTerminate()
``` and ```
BadMethodCallException:
Symfony\Component\VarDumper\Cloner\Data objects are immutable.

in symfony\var-dumper\Cloner\Data.php (line 152)
Data->offsetSet() in symfony\http-kernel\DataCollector\EventDataCollector.php (line 92)
EventDataCollector->setCalledListeners() in symfony\http-kernel\DataCollector\EventDataCollector.php (line 74)
EventDataCollector->lateCollect() in symfony\http-kernel\Profiler\Profiler.php (line 100)
Profiler->saveProfile() in symfony\http-kernel\EventListener\ProfilerListener.php (line 135)
ProfilerListener->onKernelTerminate() in symfony\event-dispatcher\Debug\WrappedListener.php (line 116)
WrappedListener->__invoke() in symfony\event-dispatcher\EventDispatcher.php (line 220)

The interesting thing (maybe?) is that '/login' returns HTTP 200, but it looks like the AJAX request is failing? But I don't have any entries in the developer console for any ajax requests... And yet the page output looks like this:
image

How to reproduce

No idea how to reproduce, as it's inconsistent. I'm assuming it's a delay with the file system, maybe? I don't know.

Possible Solution

No response

Additional Context

No response

@radar3301
Copy link
Contributor Author

heh... I found these gems in the 'index.csv' file:

L364: 062a6b,404
L726: 02
L728: (empty line)

@MatTheCat
Copy link
Contributor

Seems to be the same issue than in #50816 and #50913.

If you, @benjaminfunk or @Pelagoss ever manage to share a reproducer, feel free to do so!

@radar3301
Copy link
Contributor Author

Is it even possible to mock concurrent file writes to the same file from two different requests?

@radar3301
Copy link
Contributor Author

Closing in favor of #50947.

nicolas-grekas added a commit that referenced this issue Jul 13, 2023
…age (radar3301)

This PR was merged into the 6.3 branch.

Discussion
----------

[HttpKernel] Skip corrupted CSV data in FileProfilerStorage

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Partially fixes #50942, improves/fixes on PR #50913, partially fixes #50816
| License       | MIT

Technically, part of this fix could go all the way back to 2.1, but since we're not sure why/how exactly the index.csv file is being corrupted in the first place, this PR should just serve as a stop-gap measure until the root cause can be identified.

A corrupted index.csv file is especially noticeable since 6.3, when the "Remove Expired Profiles" feature was added by #47352 .

RE: improves/fixes on PR #50913:
Warnings are (usually?) only escalated to errors in debug mode, so having a try/catch is a bit more overhead than I think is actually needed, and I believe just checking that the line read from the csv is not corrupted is the better/faster option. Granted, the profiler should really only be active in debug/non-production modes anyway, but "should" and reality usually don't align...

`@alamirault` `@MatTheCat` `@benjaminfunk` `@Pelagoss` `@derrabus`

Commits
-------

b4e942d Update FileProfilerStorage.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants