I've dealt with this before - usually the lean happens because the cactus is growing toward its light source, not necessarily rot. Try rotating the pot a quarter turn every week or so, and make sure it's getting even light from all sides; if it's been tilting toward a window, that's probably your culprit. Root rot would show up as mushy spots or a foul smell when you water, so if the stem feels firm you're likely fine. Staking isn't really necessary for a barrel cactus, but if the tilt gets severe you could gently support it with a padded stake while you gradually reorient the light exposure.