Running recent CentOS update on machine with 512 MB of RAM caused yum to run out of memory. Thinking nothing of it, I stopped it to see what can be done. After stopping all services I was greeted with "Warning: RPMDB altered outside of yum" and "Found 93 pre-existing rpmdb problem(s), 'yum check' output follows".
After trying a lot of things, I found the one that works. Removing older package without removing its dependencies and reinstalling the newer one worked a charm:
# rpm --erase --nodeps --noscript yum-plugin-fastestmirror-1.1.31-42.el7.noarch
# yum reinstall -y yum-plugin-fastestmirror
Of course, the same can be scripted but I leave that to more daring souls. :)
PS: Yes, the same procedure works on Red Hat too.