0

I'm building a webtoon with CraftCMS 4 but facing this issue: SQLSTATE[HY000]: General error: 5 Out of memory (Needed 418490224 bytes)

Screenshot: https://i.sstatic.net/oMKud.png

All entries are a Structure section. Two types of story: series and single. The series include child entries (level 2, chapters). Here is how I display the nested entries on pages.

On home/category/search page, I display parent entries {% paginate craft.entries().section('stories').level(1).limit(24).orderBy('dateUpdated desc') as pageInfo, pageEntries %}. Each parent entry has the number of the latest chapter {% set num = entry.children().level(2).orderBy('id desc').one() %}

Demo entries: https://i.sstatic.net/CJxg7.png

When reading a story (series), click the parent entry link where I show child entry titles (chapters) {% set craft.entries().section('stories').level(2).orderBy('id desc').all() %} Click each chapter to read. On each chapter page, I show all chapters of a parent entry and show related parent entries, for example, newest or hot entries.

I use {% cache for 5 minutes %} for all loops {% for %} but the issue is still available. What should I do to fix it? Does Redis cache work? If yes, can you show me step by step to install it? I found this guide on CraftCMS 3 docs but I don't know how to set it. Which folder will I install the yii2-redis library? Run composer in the root folder of Craft or somewhere?

Thanks for your answer! P/s: I'm, a web builder, not knowledgeable about coding without the detailed guides or samples. I like CraftCMS because of twig templates. It's easy to code.

8
  • Sounds like the underlying MySQL server has run out of memory. What sort of environment are you getting this on... locally? Usual MAMP, DDEV, etc.?
    – Brad Bell
    Commented Apr 3, 2023 at 3:02
  • It's on production environment, DigitalOcean 1GB RAM, Maria DB. I'm not sure if I build the web in the wrong way, so there are many requests to the database and make this error happen. If this issue is about the limitation of my server, what should I do?
    – Alex
    Commented Apr 3, 2023 at 5:26
  • 1
    If you bump the VM to 2GB, can you reproduce the error?
    – Brad Bell
    Commented Apr 3, 2023 at 14:13
  • I'm unable to upgrade my managed vps this time. I've contacted the provider about this issue, and they increased the memory limit of PHP to 512MB, wait time, etc. The error is still happening. I found this article craftcms.com/knowledge-base/query-batching-batch-each I think it may refer to my issue due to large data set. I also enabled CRAFT_DB_USE_UNBUFFERED_CONNECTIONS=true in the file .env as stated in this guide (craftcms.com/docs/4.x/config/db.html#useunbufferedconnections)
    – Alex
    Commented Apr 4, 2023 at 2:40
  • When I added new child entries in the CraftCMS admin, viewed the web and the error happened sometimes. In general, I tried some ways: eager-loading with(['image_field']) to fetch entries, unbuffered database connection (just found the article and enabled it in the file .env), {% cache for 5 minutes %} tag for loops, PHP memory limit expansion (512MB, RAM 1GB). That's it.
    – Alex
    Commented Apr 4, 2023 at 2:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.