Why is the accountsd process eating so much CPU?

Why are the accountsd and securityd processes using so much CPU on OS X 10.10.3?
I am on a Early 2011 Macbook Pro.

What are these processes for? Is it safe to kill them? The machine has only been up 4 hours so has been rebooted recently.

enter image description here


In Mail.app's application's preferences, I deselected "Accounts > Advanced > Automatically Detect and Maintain Account Settings" on two Google accounts, and CPU usage returned to normal.


This issue appeared with macOS Catalina for me, and only if I have the Mail app open without an internet connection.

Going to Mail->Window->Connection Doctor->ShowDetail, it looks like there's an infinite loop running, which tries to connect to the mail server.

The only temporal solutions are to either disable the account which is causing trouble (via Mail Preferences) or to quit the Mail app when I'm offline.


EDIT (about one year after original post): The issue has disappeared for me, without me changing anything on my system.

Apparently either Apple or the email provider have fixed the issue.