I sometimes have these troubles. My main objective with main character names is to keep them short since they will be typed a lot through the course of a novel. (I’m a slow typist.) I also keep handwritten notes on character descriptions. This helps if a minor character comes back after having been away for a while. Hair and eye color and age and stuff are jotted down if they are mentioned at one point or another. Helps the continuity.
My first book had a character with the same first name as my brother. My niece actually asked if I was mad at her father when I wrote the book because the character was such an ass. Holy cow! It never crossed my mind.