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

PHP memory limit failure when executing expiry prune via cron job. #15

Open
sudo00 opened this issue Oct 29, 2019 · 4 comments
Open

PHP memory limit failure when executing expiry prune via cron job. #15

sudo00 opened this issue Oct 29, 2019 · 4 comments

Comments

@sudo00
Copy link

@sudo00 sudo00 commented Oct 29, 2019

Describe the bug
We have cron executing https://domain.com/yourls-api.php?signature=&format=simple&action=prune&scope=expired that cannot be executed until an error occurs.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in /var/www/html/includes/vendor/aura/sql/src/ExtendedPdo.php on line 748
The cause for this may be a large number of records.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://domain.com/yourls-api.php?signature=&format=simple&action=prune&scope=expired
  2. See error

Expected behavior
It will remove old links and execute without errors

Actual behavior
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in /var/www/html/includes/vendor/aura/sql/src/ExtendedPdo.php on line 748

@joshp23

This comment has been minimized.

Copy link
Owner

@joshp23 joshp23 commented Oct 30, 2019

Your system appears to be attempting to allocate 4 kilobytes of memory to this operation, which is a reasonable amount. Adjusting the amount of memory allocated to php to 256 or 512 will likely fix this error.

See this answer on Stack Overflow.

@joshp23 joshp23 changed the title Unable to delete shortened URL's PHP memory limit failure when executing expiry prune via cron job. Oct 30, 2019
@vitalyzhakov

This comment has been minimized.

Copy link
Contributor

@vitalyzhakov vitalyzhakov commented Oct 30, 2019

@joshp23 , hello!
Thanks for your answer!

We using official docker container for yourls https://github.com/YOURLS/docker-yourls and limit container by 512 MB RAM. Container limit is not a bottleneck, you can see it by container's metrics.
yourls-container-metrics.

May be for prune links must be using batch sql queries?

I can not find any code likes prune to debug it.

@vitalyzhakov

This comment has been minimized.

Copy link
Contributor

@vitalyzhakov vitalyzhakov commented Nov 1, 2019

If I correctly read code, it down in
https://github.com/joshp23/YOURLS-Expiry/blob/master/expiry/plugin.php#L1456-L1473

And it must be changed to use less memory usage methods https://github.com/auraphp/Aura.Sql/blob/3.x/docs/yield.md.

@joshp23 , is it right?

@joshp23

This comment has been minimized.

Copy link
Owner

@joshp23 joshp23 commented Nov 1, 2019

seems like you found the code that executes the prune.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.