Score:1

Trying to get to the bottom of an out of memory error related to the database

cn flag

I've inherited a highly problematic site built in Drupal 7. Upon installing the site on my dev space I get a 'This page isn’t working' error 500. Looking at the web logs I get this message:

lmu.[sitename].co.uk [Sat Apr 23 15:39:03 2022] [error] [client 86.174.32.32:0] AH01215: PHP Fatal error: Out of memory (allocated 56098816) (tried to allocate 459743 bytes) in /home/sites/[sitename].co.uk/public_html/lmu/includes/database/database.inc on line 2324: /home/sites/[sitename].co.uk/public_html/lmu/index.php

The memory_limit was 128M and is now 512M but I get exactly the same error with the same numbers etc.

Is this to do with something contained within the DB?

Additional Edits:

Another, maybe related, issue is that on another server the site runs but only with PHP 5.6 (both updated and non-updated versions of the site). On the server that this question pertains to it is also running 5.6. However, when I attempt to use 7.4 the site still fails but I get a different error message relating to the Database that might provide further clues:

Uncaught exception thrown in shutdown function.

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.: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 15563655396262a9bd4cef06.08066829 ) in lock_release_all() (line 269 of /home/sites/[sitename].co.uk/public_html/lmu/includes/lock.inc).

cn flag
It’s basically impossible to say without profiling the page request - if the allocated byte amount was large, you could probably be confident enough to point to that script being the culprit, but it’s not, it’s 0.5mb. So either that db call was isolated, and just the unlucky loser that tried to get some memory when all the rest was gone, or that db call is being invoked recursively/exhaustively by something else which is stopping the memory from being reclaimed. Either way you need to wind back through the stack trace and see what’s going on
id flag
Agreed. The last code to allocate memory isn’t necessary the culprit. But it could be.
cn flag
Cheers @Clive. I'm not sure of the best procedure to investigate the stack in this context (I'm coming from a frontend background, pls forgive me!). Could you please give me some pointers if possible?
cn flag
Oh I missed the "same numbers" bit before, that's actually pretty crucial, my bad - are you positive about that? If so, 56098816 is exactly 56mb, which suggests your PHP limit isn't what you think it is...maybe you're editing the wrong php.ini file or haven't restarted php-fpm/apache after altering it?
cn flag
Also make sure you're checking the limit in the right context - it's not unusual, in some environments, for there to be different PHP config for CLI vs web, so if you're getting 128mb on the command line, it doesn't necessarily mean the web server is getting the same amount. Simplest way to check is to add a test.php in the web root containing `<?php echo ini_get('memory_limit');` and visit test.php in the browser.
cn flag
@Clive Cheers - <?php echo ini_get('memory_limit'); returns 512M (placed in public_html).
cn flag
I've added some additional info the the question.
cn flag
Possibly a server memory issue: https://stackoverflow.com/questions/13955914/php-out-of-memory-error-even-though-memory-limit-not-reached
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.