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

Fix high memory usage in CleanupHelper #148

Closed
zepich opened this issue Oct 25, 2023 Discussed in #147 · 0 comments
Closed

Fix high memory usage in CleanupHelper #148

zepich opened this issue Oct 25, 2023 Discussed in #147 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@zepich
Copy link
Member

zepich commented Oct 25, 2023

Issue

The CleanupHelper, executed in the frontend API request, loads all submissions that need to be deleted (https://github.com/mosparo/mosparo/blob/master/src/Helper/CleanupHelper.php#L65). This can be a large number of submissions. The execution of the query will fill the memory until the memory_limit (usually 128 MB) is reached and the process crashes.

Reported by

Discussed in https://github.com/orgs/mosparo/discussions/147

Originally posted by brendofreitas October 19, 2023
I found an error when using mosparo on a large scale, I verified that it is a memory problem. I found a solution that is not so suitable:

https://stackoverflow.com/questions/561066/fatal-error-allowed-memory-size-of-134217728-bytes-exhausted

However, I verified that a different type of lib can also be used to avoid this problem:
https://serverfault.com/questions/400434/php-mysqlnd-or-php-mysql

The error log was:
"

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16384 bytes) in /mosparo/vendor/doctrine/dbal/src/Driver/PDO/Statement.php on line 121



Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in /mosparo/vendor/composer/ClassLoader.php on line 571



Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in /mosparo/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php:353
Stack trace:
#0 /mosparo/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php(353): PDOStatement->execute()
#1 /mosparo/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php(120): Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler->doWrite('078f5ab84ad06b3...', '_sf2_attributes...')
#2 /mosparo/src/Session/DatabaseSessionHandler.php(64): Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler->write('078f5ab84ad06b3...', '_sf2_attributes...')
#3 /mosparo/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php(73): Mosparo\Session\DatabaseSessionHandler->write('078f5ab84ad06b3...', '_sf2_attributes...')
#4 [internal function]: Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy->write('078f5ab84ad06b3...', '_sf2_attributes...')
#5 {main}
thrown in /mosparo/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php on line 353

"

How can we resolve this? I believe that when you are searching the bank it is listing all the data to get to a point, which is not necessary. This increases memory usage to a maximum, slowing down and crashing the application and generating this error.

@zepich zepich added the bug Something isn't working label Oct 25, 2023
@zepich zepich self-assigned this Oct 25, 2023
@zepich zepich mentioned this issue Nov 1, 2023
@zepich zepich closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant