Say someone is on trial for a murder they committed. During the trial, one of the witnesses, a friend of the defendant, admits that it was actually they who were the killer. It seems that this would be enough to create reasonable doubt and get an acquittal, or even possibly have the state drop the charges because they now believe that they should be charging this other person.
After the trial ends, the friend presents irrefutable proof that they weren't actually the murderer. Of course, this friend could be charged with perjury, obstruction, etc... but the original defendant can't be re-tried for the murder because of double jeopardy, and their friend can't be tried (or won't be found guilty) because of the evidence that he didn't do it.
Is there a flaw in this system? Something that prevents someone from actually doing this?
Related: Can someone get protection under Double Jeopardy for a crime by arranging to be put on trial with fake evidence that is then disproven?
Side-note; something just like this happened in an episode of Law and Order; though I had been wondering about this long before seeing that.