Fixing `ghost 500 select `products`.*...`
I've been tracking analytics ever since I launched a new VM to host my blog. I was surprised that there was no traffic since.
I was wondering if whether it was an issue with Google: perhaps not referencing my blog any longer since it somehow detected that the server IP had changed. Unlikely since it should be completely normal that a server's IP changes.
Intrigued, I googled something on my site, clicked the link and got this error:
If I went to www.wafrat.com directly, then I'd get a mysql error trace:
ghost 500 select `products`.*, `posts_products`.`post_id` as `_pivot_post_id`, `posts_products`.`product_id` as `_pivot_product_id`, `posts_products`.`sort_order` as `_pivot_sort_order` from `products` inner join `posts_products` on `posts_products`.`product_id` = `products`.`id` where `posts_products`.`post_id` in...
So I ssh'ed into the VM and ran top
to see CPU and memory usage:
It looked like kswapd0
and snapd
hogged the CPU. I googled them and learned that snapd is the system's package manager, and that kswapd is what runs when the system runs out of memory and starts swapping memory around. One website suggested that the fix was to stop snapd altogether. Not a good idea!
Instead I went for installing swap just like I did in https://www.wafrat.com/resizing-swap/#setting-up-the-swap.
As soon as set up the swap, the system stabilized: snapd and kswapd0 stopped using resources, and everything went back down.
I refreshed the page and voilà, the blog is back up!