When Devin P. Kelley turned a small-town Texas church into a bloody killing ground, he also exposed the glaring flaws of the national background check system for gun buyers.

Mr. Kelley, convicted of assaulting his wife and stepson while serving in the Air Force, should not have been able to buy guns. But the Air Force admitted on Monday that it had failed to report the conviction, revealing a system that has missed many offenders, from those who have committed domestic abuse to mass killers like Dylann S. Roof, the Charleston church gunman, who was approved because local prosecutors did not respond within a three-day time limit.

A police report that surfaced on Tuesday said Mr. Kelley had escaped from a psychiatric hospital in 2012. Federal law prohibits gun possession by a person who “has been committed to any mental institution,” but it was unclear if that had happened to Mr. Kelley.

Since the National Instant Criminal Background Check System was created nearly two decades ago, with the intent to keep guns out of the hands of criminals, drug users and people with severe mental illness, it has rejected more than a million would-be gun purchases. But it is only as effective as the records it contains, and it depends on thousands of hospitals and law enforcement agencies to voluntarily produce accurate and timely information.