docker icon indicating copy to clipboard operation
docker copied to clipboard

Can't log in due to out of memory error despite setting MEMORY_LIMIT

Open naggie opened this issue 5 years ago • 10 comments

Hi,

I got the docker-compose.yaml running, and database initialised. After adding MEMORY_LIMIT: 5000 to the environment: section of the koel container, koel:sync worked without exiting blindly.

However, when attempting to log in the page just refreshes. Looking at the server log, a request to /api/data failed with a 500 error.

Using developer tools, the error message was:

image

This would seem to indicate that the MEMORY_LIMIT only applies to the php executable and not php-fpm where the main koel process is running.

I suppose the entrypoint could add the memory limit to the fpm config as well to fix this.

Thanks for maintaining this docker-compose project!

naggie avatar May 13 '20 19:05 naggie

Hi, Thanks a lot for that report :). I also have had problems with login. After 3-5 tries it usually succeeded, which would be explained by it being a memory allocation problem. I could never get any log, I'm glad to see you could get an error json. Just for information ,this image does not use php-fpm but apache and modphp. I'll take a look on it but don't know when I'll have time. Now that I have a trail, I can try something to fix it :)

Hyzual avatar May 14 '20 15:05 Hyzual

No problem. I found that the problem only occurred after adding a lot of files with sync -- given it was a call to /api/data this makes sense though I'm still surprised such a request needs so much memory, probably one for optimisation in koel.

Login still fails after 10 attempts, probably because in my case I have a lot of files, I suspect your case was marginal.

I might get time to PR a fix tonight or this weekend, I suppose it will be a case of whoever gets time first

Thanks!

naggie avatar May 15 '20 07:05 naggie

It seems the issue can also be masked with the same behaviour. I got image

For the same request, but I guess that was a result of rebuilding my container. I suspect the secrets have changed (specifically JWT_SECRET) or something.....

So wiped the database and tried again, this time with a patch performed by koel-entrypoint to set the apache modphp memory limit. Now I get permission denied on laravel.log.

I'llkeep investigating.

Interestingly, on the first koel:init it says the JWT secret already exists. Any idea why?

naggie avatar May 16 '20 11:05 naggie

Thanks for the investigations ! Yes, if the JWT_SECRET changes, the token becomes invalid and it locks you out. Yeah, the laravel.log permission is really annoying too. I wonder if the entrypoint should do something about it. It's surprising, the JWT secret is not supposed to already exist. There is a lot of caching going on with Laravel though, try php artisan cache:clear. It has fixed some issues for me in the past :). koel does not read directly from env variables, it reads once and caches somewhere.

Hyzual avatar May 16 '20 12:05 Hyzual

Hi! In 2edf076628b5012f32a7fa18e29507bd3079dc01 I've added a php.ini file with a higher memory limit (512MB). From my tests this week, it looks like I no longer encounter the memory issues and I can login straight away. Previously it took 5 or 6 refreshes to log in. Could you pull the latest image and give it a try? 😊

Hyzual avatar Dec 11 '20 17:12 Hyzual

Oh that's great. I will certainly give it a go soon, thanks for the change.

naggie avatar Dec 11 '20 20:12 naggie

I can get as far as koel::init, but when I run sync, the command exits with status 255:

image

It's a shame there's no error output to give a hint at what's wrong. There's no laravel.log either.

I got the same invalid token error when trying to log in (the page just refreshes -- needed to check the console.)

php artisan cache:clear didn't help. Note this is straight out of the box -- I removed my volumes and images etc.

naggie avatar Mar 11 '21 17:03 naggie

About the error when scanning, I don't know what to say, I don't think I can help you :confused:. I've just tried now rebuilding from the Dockerfile and with my test media (some .ogg, some .mp3, some .flac files) scanning works, even when it complains. I guess I can only suggest to open an issue at https://github.com/koel/koel. About the invalid token, it looks like something is wrong somewhere indeed. I would have advised to run cache:clear too... Indeed without errors it's hard to have a clue on what's going on.

Hyzual avatar Mar 16 '21 21:03 Hyzual

Turns out I was running an older image after all -- see https://github.com/Hyzual/docker-koel/issues/59#issuecomment-801411165 -- sorry for the hassle.

It scans now, though it got stuck on a probably-invalid ID3 tag: image

I'll investigate and/or raise a koel issue for that.

Thanks for the effort of making the docker koel image, by the way.

I had no issue with a token when attempting to log in with the latest image; however it get a 500 "Server error" JSON response again. Perhaps my collection is too large at 16,000 songs. I'll try increasing the memory limit further later. It's a bit odd how so much memory is required and it apparently scales with size of media library, maybe koel is loading everything at once or something.

naggie avatar Mar 17 '21 20:03 naggie

OK I tried 2048M by editing php.ini and swapping the line image: hyzual/koel for build: . and now I can log in!

I think I might raise an issue in the koel repository or check out the code. There's no way a page should use that much memory even if the media repository is large.

naggie avatar Mar 17 '21 20:03 naggie