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

Sync belongsToMany throw allowed memory error #368

Open
josearagon opened this issue Sep 7, 2020 · 4 comments
Open

Sync belongsToMany throw allowed memory error #368

josearagon opened this issue Sep 7, 2020 · 4 comments
Assignees

Comments

@josearagon
Copy link

josearagon commented Sep 7, 2020

Describe the bug
Sync post relatedCategories throw PHP Fatal error: Allowed memory size of ********* bytes exhausted
Post is a cacheable model and category is a cacheable method.
It only pass in production envioronment.

When I try to update related categories from a post, I get a tipical memory error :(.

Eloquent Query
Please provide the complete eloquent query that caused the bug, for example:

public function relatedCategories()
    {
            return $this->belongsToMany(Category::class)->withTimestamps();
    }
$post-> relatedCategories()-> sync($request->related_categories);

Stack Trace
2020/09/07 14:16:16 [error] 17231#17231: 59 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4096 bytes) in /CODE/www/.com/httpdocs_9d7999fc5ca37605867751000c54677cdfd1027c/vendor/predis/predis/src/Connection/StreamConnection.php on line 345
PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 16384 bytes) in /CODE/www/
.com/httpdocs_9d7999fc5ca37605867751000c54677cdfd1027c/vendor/symfony/error-handler/Error/FatalError.php on line 91" while reading response header from upstream, client: , server: *******.com, request: "PUT /360panel/posts/45530 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: ".com", referrer: "https://******.com/360panel/posts/45530/edit"

Environment

  • PHP: 7.3.9
  • Laravel: 7.27.0
  • Model Caching: 0.10.2
  • Redis.

Additional context
Add any other context about the problem here.

@mikebronner
Copy link
Owner

@josearagon Please provide the full stack trace.

@josearagon
Copy link
Author

@mikebronner I just edited the original comment with the full stack trace.
Always need more memory. We try to increase memory_limit but it's never enough.

Thanks a lot

@josearagon josearagon changed the title Sync belogsToMany throw allowed memory error Sync belongsToMany throw allowed memory error Sep 7, 2020
@mikebronner
Copy link
Owner

@josearagon Where are you getting this stack trace from? I'm looking for the full stack trace from /storage/logs/laravel.log. This seems to be only a partial stack trace.

@josearagon
Copy link
Author

Interestingly, Laravel rarely logs an error in this case. The error occurs at php level.

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

2 participants