The California court's website states that cohabiting spouses is a conclusive presumption[1] and the exceptions to overturning are very limited, even with genetic testing. I'm not a lawyer and can't easily research precedent, but the law seems pretty clear that if you don't challenge before the 2nd birthday of the child, it can't be overturned. There may be other restrictions as well.
It seems like recent anecdotes I can find relate to the 2 year deadline. The father didn't challenge paternity at the time of divorce, found out he was not biological father (or that he could challenge) later, but it was too late.
Hopefully we can all agree it would be shitty to disown a kid you've been raising for years because you found out you weren't the biological father, but I can certainly have empathy for someone who has limited (or no) visitation and is stuck shelling out money for someone else's kid.
[edit]
It looks like the law was revised recently as well, so amybe the court website is out of date on some of this? AB2684 mentions "rebuttable presumptions" and was passed in 2018, going into effect in 2019. IANAL and don't have time to follow up on this.
Those laws were passed before DNA testing. It seems like they could be updated for that.
I think a better solution is taxpayers shouldering the burden than punishing an innocent individual (actually a victim).
Example: the father may take drugs to relieve the pain. Said father may invite the child to join him, setting up the child for life.
One man had won a court settlement when he was young and the woman applying for benefits remembered reading about him in the paper, so she put his name and address on the application to get the money. The court ordered him to start paying child support. He tried to fight it in court with a DNA test, but you need to serve the mother and neither the court nor the social welfare agency would release her address.