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

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

Open
naggie opened this issue May 13, 2020 · 10 comments
Open

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

naggie opened this issue May 13, 2020 · 10 comments

Comments

@naggie
Copy link

naggie commented May 13, 2020

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!

@Hyzual
Copy link
Collaborator

Hyzual commented May 14, 2020

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 :)

@naggie
Copy link
Author

naggie commented May 15, 2020

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
Copy link
Author

naggie commented May 16, 2020

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?

@Hyzual
Copy link
Collaborator

Hyzual commented May 16, 2020

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
Copy link
Collaborator

Hyzual commented Dec 11, 2020

Hi!
In 2edf076 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? 😊

@naggie
Copy link
Author

naggie commented Dec 11, 2020

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

@naggie
Copy link
Author

naggie commented Mar 11, 2021

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.

@Hyzual
Copy link
Collaborator

Hyzual commented Mar 16, 2021

About the error when scanning, I don't know what to say, I don't think I can help you 😕. 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.

@naggie
Copy link
Author

naggie commented Mar 17, 2021

Turns out I was running an older image after all -- see #59 (comment) -- 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
Copy link
Author

naggie commented Mar 17, 2021

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.

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

No branches or pull requests

2 participants