ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

QUESTION: PHP Error - Allowed memory size

Open DenisFlorin opened this issue 3 years ago • 2 comments

Hello,

I'm not sure if this is a bug, but after upgrading from WordPress 5.9.3 to WordPress 6.0.1 the plugin started to throw errors while editing categories.

Below is the error: [04-Aug-2022 08:48:27 UTC] PHP Fatal error: Allowed memory size of 671088640 bytes exhausted (tried to allocate 113247840 bytes) in /app/web/wp-content/plugins/elasticpress/includes/classes/Indexable.php on line 335 [04-Aug-2022 08:48:27 UTC] PHP Error: Allowed memory size of 671088640 bytes exhausted (tried to allocate 113247840 bytes) in /app/web/wp-content/plugins/elasticpress/includes/classes/Indexable.php on line 335, request: POST /wp-admin/edit-tags.php, request_id: 6f79e5cf7f441cb1cc86a8e9af506d8a

Right now, the memory limit is set to 640MB, which is a lot, and I don't understand why it's not working anymore. I'm using the latest version of the plugin.

I am looking forward to hearing from you.

Kind regards,

DenisFlorin avatar Aug 04 '22 09:08 DenisFlorin

Hey @DenisFlorin,

Are you seeing that behavior while editing all terms? Or specific ones, like those with more posts associated? If that is happening just on terms with lots of posts associated with them, you could use the EP_SYNC_CHUNK_LIMIT constant to tell ElasticPress to send posts in batches instead of queueing everything.

Let me know your findings, okay? Thanks!

felipeelia avatar Aug 04 '22 16:08 felipeelia

Hello @felipeelia,

The save works fine for categories which have fewer posts.

I've enabled the mentioned constant and now I have another problem We don't get anymore the allowed memory limit, but we get a 504 timeout. Some categories have over 20k posts associated. Below is the stack trace:

[05-Aug-2022 09:17:37] WARNING: [pool www] child 116662, script '/app/web/wp-admin/edit-tags.php' (request: "POST /wp-admin/edit-tags.php") executing too slow (62.507561 sec), logging
[05-Aug-2022 09:17:37] NOTICE: child 116662 stopped for tracing
[05-Aug-2022 09:17:37] NOTICE: about to trace 116662

[05-Aug-2022 09:17:37]  [pool www] pid 116662
script_filename = /app/web/wp-admin/edit-tags.php
[0x00007fc4aa014070] preg_replace_callback() /app/web/wp-includes/formatting.php:3431
[0x00007fc4aa013f50] convert_smilies() /app/web/wp-includes/class-wp-hook.php:307
[0x00007fc4aa013e70] apply_filters() /app/web/wp-includes/plugin.php:191
[0x00007fc4aa013da0] apply_filters() /app/web/wp-content/plugins/elasticpress/includes/classes/Indexable/Post/Post.php:489
[0x00007fc4aa013c40] prepare_document() /app/web/wp-content/plugins/elasticpress/includes/classes/Indexable.php:323
[0x00007fc4aa013b60] bulk_index() /app/web/wp-content/plugins/elasticpress/includes/classes/SyncManager.php:189
[0x00007fc4aa013ad0] index_sync_queue() /app/web/wp-content/plugins/elasticpress/includes/classes/SyncManager.php:132
[0x00007fc4aa013a40] index_sync_on_chunk_limit() /app/web/wp-includes/class-wp-hook.php:309
[0x00007fc4aa013960] apply_filters() /app/web/wp-includes/class-wp-hook.php:331
[0x00007fc4aa0138f0] do_action() /app/web/wp-includes/plugin.php:476
[0x00007fc4aa0137f0] do_action() /app/web/wp-content/plugins/elasticpress/includes/classes/SyncManager.php:91
[0x00007fc4aa013780] add_to_queue() /app/web/wp-content/plugins/elasticpress/includes/classes/Indexable/Post/SyncManager.php:462
[0x00007fc4aa013660] action_edited_term() /app/web/wp-includes/class-wp-hook.php:307
[0x00007fc4aa013580] apply_filters() /app/web/wp-includes/class-wp-hook.php:331
[0x00007fc4aa013510] do_action() /app/web/wp-includes/plugin.php:476
[0x00007fc4aa013400] do_action() /app/web/wp-includes/taxonomy.php:3346
[0x00007fc4aa013250] wp_update_term() /app/web/wp-admin/edit-tags.php:183
[05-Aug-2022 09:17:37] NOTICE: finished trace of 116662

Do you have other ideas?

Kind regards,

DenisFlorin avatar Aug 05 '22 09:08 DenisFlorin

Closing this in favor of #2933.

felipeelia avatar Sep 15 '22 14:09 felipeelia