1 Samuel 22:20-23, we see that Ahimelech was killed by the order of Saul and his son Abiathar escaped:
20 But one son of Ahimelech the son of Ahitub, named Abiathar, escaped and fled after David. 21 Abiathar told David that Saul had killed the priests of the LORD. 22 Then David said to Abiathar, “I knew on that day, when Doeg the Edomite was there, that he would surely tell Saul. I have brought about the death of every person in your father’s household. 23 “Stay with me; do not be afraid, for he who seeks my life seeks your life, for you are safe with me.”
2 Samuel 8:17, Ahimelech is referenced as one of David's priests, and the son of Abiathar:
17 and Zadok the son of Ahitub and Ahimelech the son of Abiathar were priests, and Seraiah was secretary,
Obviously both can't be true, but I can't seem to find any compelling information that would explain this reversal of names.