Asyncio_loop Over 100% CPU, middlewared, GUI slow - Seems Docker / GHCR / Custom App Related

Funny, I took another attempt at fixing this last night (probably like the 5th time now). I am not sure if I fixed it but what I saw in the logs was a job trying to check over and over for images that didn’t exist. I tracked it down to images that didn’t have a tag at all!

When you replace an image with a new digest but same tag (like latest) the old image ends up having a tag like <none>. Each time you upgrade your stack and replace the existing it leaves a dangling image with a tag of <none>

e.g.

n8nio/n8n:<none>
n8nio/n8n:latest

You can see this by running

docker images --format '{{.Repository}}:{{.Tag}}' | sort

My hunch is that the update checker is still checking these images and gets into a loop. I had about 20 images with tags of <none> and I think it was looping trying to check them over and over again.

What I ended up doing was pruning all dangling images by running:

docker image prune -a -f

then restarting the middleware service

systemctl restart middlewared

I ended up creating a cron job to do this too.

The jury is still out on whether it fixed it or not but it’s been over 24 hours and asyncio_loop isn’t using 110% CPU anymore (20-40% which I still think it quite high).

1 Like

I think you might be on to something. I also had a tone of old images that were tagged with

Wound up freeing about 100gb of old images. I’ve restarted middlewared afterwards and we’ll see what happens. I’ll also note that middlewared restart MUCH faster after pruning those old images.

1 Like

Just tried it out for myself, I think you got it!
When I access the webui asyncio_loop starts using the cpu, which is expected, problem until now was after you exited the webui asyncio_loop kept using cpu and gradually increased over time unless you restarted middlewared.
I’m no longer seeing any activity in the asyncio_loop after I exit the webui, which was only possible with a middlewared restart before technotim’s fix.
I’ll keep an I on it and report back if things change.

Well that didn’t last long. All I did was update an app and it’s back.

I came here to say the same thing

 674934 root      20   0 3768432 990096  34060 S  98.7   0.4     36,06 asyncio_loop

It’s driving me crazy

2 Likes

there is definitely some errant processes or sticky leftovers floating around once docker is enabled.

just about any login / logout leave idle cpu usage higher so I am essentially having to prune and restart middleware after any login… wether I mess with docker or not… just seems to be the only way to quiet it down for a bit

as an aside… netdata seems to be pretty resource hungry compared to other netdata instances I have run. .to be fair ix have enabled quite a bit… but still just having netdata running with no web sessions doubles the idle cpu on a quad core… seem egregious

1 Like

Just bumping this thread again to say it’s still happening even after 25.04.2.6. super frustrating. I’m going to set up a cron job to run ever 12 hours or something like that.

Hi all,

just wanted to say, I have the same problem basically from the beginning since I use truenas (~3 months, since 24.10.2.4). I’m using some custom docker apps via yaml, and some communtiy apps. It’s not as extreme as in your case (CPU is at ~60%). Restarting middleware fixed it temporarly. I just tried to delete all unused docker images, will see how this continues.

Yup, super frustrating. Almost find it hard to believe the problem isn’t widespread, or people just don’t notice. Also, crickets from the Truenas guy awalkerix who posted earlier in the thread, I sent him what he wanted months ago and no feedback. Oh well.

2 Likes

I am running 25.04.2.4, and asyncio_loop was at the top of “Top” and not moving, and all my cron jobs ( I have nine cron jobs configured) were not getting triggered, also the GUI was frozen so had to ssh to killl the process to make it all come back again.

Yes very frustrating.

For me, the system load is not so severe; it only slowly becomes a issue after several days.
A few days ago, I had an idea and shifted my tests to two things:

  1. I haven’t login to the webui of truenas for several days after restarting middlewared via CLI. After 5 days the systemload was still as low as right after restart. So maybe it has something to do with the webui?
  2. I switched of “Check for docker image updates” under Apps → Configuration → Settings.
    No outcome yet, as I have just switched it off.

Any thoughts?

Just wanted to say I’m another victim of this. Nothing I do fixes it, any new ideas?

I am back again with the same issue.

Still running ”OS Version:25.04.2.6”

Top showing the following:

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND

2971 root 20 0 6377840 2.3g 33000 S 110.6 1.9 13d+17h asyncio_loop

This again is causing my cron jobs to trigger sporadically.

Restarting the process is only fixing the issue temporarily.

Any appropriate suggestions ???

I have had to invoke the ”systemctl restart middlewared”, as none of my critical cron jobs have been triggered, which makes my system unstable.

Perhaps I should have a cron job restarting ”middlewared” every night, but then how can I trust that it will be actioned.

Not good…

Guess what !

All my cron jobs have sprung back to life…

So 7 days after the restart of ”middlewared”, ”asyncio_loop” has now started to be listed at the top of Top as shown below.
GUI, and cron jobs still not affected, but I guess once it starts hitting the 100% cpu mark, the problem will return.

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND

2964 root 20 0 3905792 895220 19924 S 61.0 0.7 43,18 asyncio_loop

Is there a solution for this issue that we can implement.

Outside of us hacking away and guessing, I think the solution has to come from the TrueNAS team. This process uses way more resources than I ever imagined, this just shined a light on it.

First time looking at this thread so do not have much background.
From my machine, asyncio is sitting using about 30-40% CPU.

I have profiled this and so far my best guess is that it is hammering the docker socket to fetch container stats. I had not actually noticed this myself, but I do not run a massive number of containers.

@technotim out of curiosity, how many docker containers are you running? I am wondering if the people most impacted by this are running a large number of apps/containers.

Are folks still sending tickets for this? Previous ones I see mentioned are either closed or private.

Thanks for looking at it! I am running 48 containers. I too have a feeling that it has to do with how they are getting container metrics.