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

libvips - glib resource temporarily available #1456

Closed
jarodium opened this issue Oct 28, 2019 · 7 comments
Closed

libvips - glib resource temporarily available #1456

jarodium opened this issue Oct 28, 2019 · 7 comments
Labels

Comments

@jarodium
Copy link

jarodium commented Oct 28, 2019

Hello,

I am getting some errors probably related to creating threads em some kind of resource temporarily unavailable.

Assume somefile.jpg has >= 3.5Mb filesize and $mime can have jpeg / webp values.

Here is the code i'm using with PHP 7.3 in a CentOS machine powered by Cpanel / Cloudlinux and with libvips 8.5.6 :

`
header("Content-type: image/$mime");

$image = Vips\Image::thumbnail("somefile.jpg",320);

$buffer = $image->writeToBuffer($ext);

echo $buffer;
`

I am having the following error messages from PHP:

`
[28-Oct-2019 09:46:31 Europe/Lisbon] PHP Fatal error: Uncaught Jcupitt\Vips\Exception: glib: Error creating thread: Resource temporarily unavailable

in vips/vendor/jcupitt/vips/src/Image.php:778

Stack trace:
#0 vips/vendor/jcupitt/vips/src/Image.php(1183): Jcupitt\Vips\Image::errorVips()
#1 vips/downloads/sizer.php(29): Jcupitt\Vips\Image->writeToBuffer('.jpg')
#2 {main}
thrown in vips/vendor/jcupitt/vips/src/Image.php on line 778
[28-Oct-2019 09:46:52 Europe/Lisbon] PHP Fatal error: Uncaught Jcupitt\Vips\Exception: glib: Error creating thread: Resource temporarily unavailable in vips/vendor/jcupitt/vips/src/Image.php:778

Stack trace:
#0 vips/vendor/jcupitt/vips/src/Image.php(1183): Jcupitt\Vips\Image::errorVips()
#1 vips/downloads/sizer.php(29): Jcupitt\Vips\Image->writeToBuffer('.jpg')
#2 {main}
thrown in vips/vendor/jcupitt/vips/src/Image.php on line 778

`
Is this something I need to check with my hosting provider?

@jcupitt
Copy link
Member

jcupitt commented Oct 28, 2019

Sorry, I don't know.

Perhaps your provider has set a very low thread limit? It would depend how they have set up your linux environment, but for example:

https://unix.stackexchange.com/questions/253903/creating-threads-fails-with-resource-temporarily-unavailable-with-4-3-kernel

I think you will need to ask them.

As a workaround, you can try reducing the size of the libvips threadpool. Put this in your startup code:

Vips\Config::concurrencySet(1);

Now libvips will only use one thread to calculate images.

@jarodium
Copy link
Author

Hello @jcupitt

I will ask my provider for that issue.
How many threads is libvips configured to use by default ( is this something that has a limit in the vips code? ) ? Or does it try to use all resources available?

@jcupitt
Copy link
Member

jcupitt commented Oct 28, 2019

By default it tries to keep all available hardware threads busy, so usually 8 threads on a four core server, for example.

@jarodium
Copy link
Author

Thank you for the help.

I will close this issue for now and give feedback as soon I have more test results.

@revathi-murali
Copy link

revathi-murali commented Mar 19, 2020

@jarodium Any update? I am facing the similar issue right now and any pointers would be of great help

cc @jcupitt

@jarodium
Copy link
Author

@revathi-murali at this time I have followed @jcupitt 's recommendation and set the Concurrency to 2.

Since I'm working in a cageFs environment with more users I can't expend that much resources or allow vips to use as it pleases. It is matter or testing values. For me, setting concurrency up to 2 works. If your software still causes the error try setting to 1 or try to lazy load or queue the images somehow for processing. If it still doesnt work, you have to acquire more resources or dedicate a machine/vps for that kind of processing.

@revathi-murali
Copy link

Thanks for your suggestion. The problem is, the issue is right now happening in PROD env and I am unable to reproduce this issue in my local or stage env. Hence having a tough time to fix it as well.

@jcupitt Any idea on when thread-reuse will go live. Do you think waiting for this #1492 to get released will be helpful?

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

No branches or pull requests

3 participants