• Resolved danielecelsa

    (@danielecelsa)


    Hello,

    I have a big db of custom post types, created by an ETL script.
    For some reason, some (many) of the CPTs created does not have the URL customized by Permalink, so I need to use the tool Regenerate in order to get the desired urls.

    The problem is that the tool crashes continuously, it just fix some url in the id range that I provide (I cannot launch it for all cpt since there are a lot) and then an error pop up:
    https://imgur.com/a/H627LWk

    I think it is not an issue related to the resources of my server since they seem to be ok when I launch Regenerate, do you have any idea why it would happen?

    Is there maybe a limit for the posts that the tool can manage in one launch?

    At the beginning, it was working fine even if I used a range of 10K cpt (not all of them needed to be fixed, I am just dividing all the db into batchs through ids so that the tool can manage them), but now even if I use batch of 500 cpt it crashes just after it finds the first 15-20 cpt to fix

    Just to make it clear, in the example that I linked, I had to refresh and restart Regenerate many times to get 77%. Each launch crashed like at 5%, 10%, 15% and so on..
    That’s because when I launch it again, the first part of the range has already been fixed, that’s why it came to 77%, but then it crashes as you can see.
    So if now I launch again, it will crash lets say at 88%

    Also, in ‘Old URI‘ section, the url is not shown as you can see.

    Thanks in advance,
    Daniele

    • This topic was modified 2 years, 3 months ago by danielecelsa.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter danielecelsa

    (@danielecelsa)

    Sorry I put the wrong link and I cannot edit the post (it is held for moderation), the right one is this one:
    https://imgur.com/a/H627LWk

    Thanks again,
    Daniele

    Plugin Author Maciej Bis

    (@mbis)

    Hi @danielecelsa

    The plugin stores all custom permalinks in a single serialized array to decrease the number of SQL requests. This method works well for small and medium-sized websites, but not for large sites with hundreds of URLs.

    Based on prior support requests from other users, the issue you are experiencing is most likely caused by the ‘max_allowed_packet’ setting.
    https://dev.mysql.com/doc/refman/8.0/en/packet-too-large.html

    When you try to add additional URIs to the array, just a small portion of them will fit within the limit. Unfortunately, the remainder will not, and the script will then fail.

    I am sorry, but I am not able to provide you any other solutions to this problem than increasing the value of ‘max_allowed_packet’ parameter.

    Thread Starter danielecelsa

    (@danielecelsa)

    Hello Maciej,

    thanks for your answer.

    Just didn’t get if you are talking about the issue that the URIs of most of the new CPTs created are wrong, or the issue that Regenerate tool crashes?

    Anyway, what would be the problem in increasing that value?
    In the link you provided it seems to me that it is safe, but your ‘I am sorry, but I am not able to provide you any other solutions‘ makes me think that maybe I am missing something ahaha

    Thanks again,
    Daniele

    Plugin Author Maciej Bis

    (@mbis)

    Hi @danielecelsa,

    To put it simply, it is not possible to store any more permalinks (URIs) since the whole array containing them is too large. What I meant was that increasing the “max _allowed_packet” value can increase the maximum size of the array, allowing it to store more permalinks.

    Because Permalink Manager is unable to add any more URIs to the permalinks array saved in the database, the new URIs are incorrect. That is also the reason why the tool crashes.

    Thread Starter danielecelsa

    (@danielecelsa)

    Ok thanks, very clear.

    So, I am trying to increase ‘max_allowed_packet’, I actually already did it on my mysql DB but I still get the issue.
    Following the link you suggested me, I see that actually it can be increased server side and client side.
    I suppose that server side is my db, and client side is your plugin Permalink Manager.
    So could you suggest me how to increase this value client side?

    Thanks in advance and sorry if I misunderstood,
    Daniele

    Thread Starter danielecelsa

    (@danielecelsa)

    Dear Maciej,

    while waiting your kind answer, I’d just like to add that I increased ‘max_allowed_packet’ almost to the max value possible (almost 1GB), through the Parameter Group (PG) feature of AWS for RDS, as they suggest to do.

    As I said, this didn’t solve the issue and Permalink keeps crashing when I try to Regenerate URI, so I am hoping you can suggest me how to increase that value client side too, hoping this can solve the issue.

    Thanks in advance,
    Daniele

    Plugin Author Maciej Bis

    (@mbis)

    Hi @danielecelsa,

    1GB is definitely more than than enough. Could you also check the browser’s console log and server’s error log? If increasing the memory did not help, the problem might be also caused by some PHP error.

    Best regards,
    Maciej

    Plugin Author Maciej Bis

    (@mbis)

    Here you can find instruction on how to display the console log in your browser:
    https://wordpress.org/support/article/using-your-browser-to-diagnose-javascript-errors/#step-3-diagnosis

    Thread Starter danielecelsa

    (@danielecelsa)

    Hello,

    sorry for late answer and thanks for yours.

    To debug, I activated define(‘SCRIPT_DEBUG’, true); in wp-config.php and monitored both Chrome Dev Tools and debug.log

    First of all, I want to say that my setup was:
    – on AWS, ‘max_allowed_packet’ almost to the max value possible (almost 1GB) (you said it is more than enough, but I left at this value)
    – on wp-config.php, I added define(‘WP_MEMORY_LIMIT’, ‘256M’); at the end of file

    When I launched Permalink and it broke, in Chrome dev Tool I only found an error 500 with a Notice:
    Constant WP_MEMORY_LIMIT already defined in /var/www/html/wp-config.php on line 110
    However, in debug.log I found the same Notice, but also a Fatal error:
    PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 41946952 bytes) in /var/www/html/wp-includes/wp-db.php on line 3159

    So I tried commenting the define line in wp-config.php
    Notice disappeared but I still had the Fatal saying the same

    Then I tried adding in wp-config.php:
    define(‘WP_MEMORY_LIMIT’, ‘1024M’);
    because I thought maybe is not enough (since Fatal says 268435456 bytes).
    In this case, I got the same situation of the first attempt, so the Notice + the Fatal error saying the same:
    PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 41946952 bytes) in /var/www/html/wp-includes/wp-db.php on line 3159

    Is there something that you think I could do at this point?

    Thanks in advance for your always kind answer,
    Daniele

    Plugin Author Maciej Bis

    (@mbis)

    Hi Daniele,

    The memory limit in the php.ini config file appears to be set to 268435456 bytes. In other words, if the ‘memory_limit’ value in php.ini is lower than the one in wp-config.php, the final value that is applied is the one in php.ini.

    Could you by any chance try to increase it directly in the php.ini file?
    https://woocommerce.com/document/increasing-the-wordpress-memory-limit/

    Furthermore, in this case, I think you should use the ‘WP_MAX_MEMORY_LIMIT’ parameter rather than the ‘WP_MEMORY_LIMIT’ parameter. The latter increases memory only for administrative panel, while the first parameter affects both the front and back-end.
    https://wordpress.stackexchange.com/a/270289/38240

    Best regards,
    Maciej

    Thread Starter danielecelsa

    (@danielecelsa)

    Thank you for your answer.

    I think I fixed it, I realized my definition:
    define(‘WP_MEMORY_LIMIT’, ‘1024M’);
    was at end of file but it must be before the line:
    /* That’s all, stop editing! Happy publishing. */

    That’s why probably this setting was not used.
    Probably the way you suggested would work too (thanks!), but seems working also this way.

    And Permalink is not breaking at the moment! 🙂

    I will let you know if something changes and it broke again (I will in case try WP_MAX_MEMORY_LIMIT), till now thanks again for your help 🙂

    Daniele

    Plugin Author Maciej Bis

    (@mbis)

    Hi @danielecelsa,

    Perfect, thank you for the update 🙂

    Best regards,
    Maciej

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Regenerate/Reset tool always crashes’ is closed to new replies.