Aterniad liked a comment+100 XP
4d ago
Solved :)
Here is my current scope:
public function scopeIsPublished($query) {
return $query
->where('status', 'published')
->whereHas('serie', function($q) {
$q->where('status', 'published');
})
->orWhere('status', 'published')
->whereNull('serie_id');
}
The sql looks like:
select * from "lessons" where ("status" = 'published' and exists (select * from "lessons" as "laravel_reserved_1" where "laravel_reserved_1"."id" = "lessons"."serie_id" and "status" = 'published' and "laravel_reserved_1"."deleted_at" is null) or "status" = 'published' and "serie_id" is null) and "lessons"."deleted_at" is null
Aterniad wrote a reply+100 XP
2w ago
Hi, I've found your topic while trying to solve the same problem on Octane (Swoole) app.
Memory leaks aren't easy to debug, but I'll try to point few key steps that helped out project:
-
If caching is involved (Memcached in our case but still), make sure you store scalar types or simple arrays. Serializing/deserializing values during I/O increases memory usage, especially with large datasets.
-
Check the "max-requests" setting when running Octane. If this value is too high, memory leaks can occur in wseemingly unrelated parts of the code even if there aren’t many leaks overall. I'd compare working with "max-requests" setting to a train, where one request can reserve seats for any number of people. Two heavy requests might fill the train to 98% capacity, and then one simple request might temporarily require 3%, overflowing the memory and causing the error to point to unrelated code.
-
Look for any usage static variables usage (simple pattern "::$"), local caches, identity maps and similar. They surely will grow in size between different requests, avoid such cases.
Hope this helps someone. Also, sorry for my English