The Air Force said on Monday that it failed to record the Texas church shooter’s domestic violence conviction in a federal database that would have kept him from buying a gun.

That glaring oversight allowed Devin Patrick Kelley, 26, to pass multiple background checks and legally purchase firearms. The stunning admission from the Air Force raises critical questions about coordination between the military and the federal background check system that is designed to keep guns from those who have lost the right to purchase them.

On Sunday, Kelley opened fire on the First Baptist Church in Sutherland Springs, east of San Antonio, killing 26 people and wounding 20 others. He was later found dead of a self-inflicted gunshot wound.

Kelley, who served at Holloman Air Force Base in New Mexico, was convicted by a general court martial on two charges of domestic assault against his wife and stepson before being released with a bad conduct discharge in 2014.

Scott Olson via Getty Images Police move flowers placed at a barricade near the First Baptist Church of Sutherland Springs on Monday. Gunman Devin Patrick Kelley killed 26 people and wounded 20 others when he opened fire during a Sunday service at the Texas church.

Under federal law, his conviction prohibited him from buying or possessing firearms. But it appears Kelley’s domestic violence offense was never entered into the federal database that gun sellers use to check the criminal history of potential buyers.

“Initial information indicates that Kelley’s domestic violence offense was

not entered into the National Criminal Information Center database by the

Holloman Air Force Base Office of Special Investigations,” said Ann Stefanek, Air Force spokesperson, in a statement. She later told CBS News that Kelley was “clearly a serious problem in the Air Force.”

She added that the Air Force will conduct a comprehensive review to ensure records in other cases have been reported correctly.

Fred Milanowski, a federal Bureau of Alcohol, Tobacco, Firearms and Explosives agent, said Tuesday that the suspect was not in any FBI database. Texas Department of Public Safety Regional Director Freeman Martin said there was nothing “in our databases that precluded him from purchasing a firearm.”

A spokesperson for Academy Sports + Outdoors, a sporting and hunting goods store, told HuffPost that Kelley purchased firearms at two of their locations, in 2016 and 2017. On both occasions, the sales were approved by the National Instant Criminal Background Check System. If his domestic violence conviction had been logged in the system, Kelley would have been flagged as prohibited from purchasing guns.

Kelley used a semi-automatic Ruger AR-556, investigators said Tuesday. Police found 15 empty 30-round magazines at the scene, along with hundreds of shell casings.

While in the Air Force, Kelley was found guilty of strangling his then-wife by putting his hands around her neck, as well as striking her, pulling her hair and kicking her, on multiple occasions between June 2011 and April 2012.

He was also found guilty of striking a child under the age of 16 on the head and body “with a force likely to produce death or grievous bodily harm.” Don Christensen, a former chief prosecutor for the Air Force, told The New York Times that Kelley assaulted his stepson “severely enough that he fractured his skull.”

He was also accused of pointing a loaded firearm at his wife, but that charge was dismissed.

It appears that domestic violence was a thread through Kelley’s life.

At least two ex-girlfriends told NBC that he stalked them after they ended relationships with him. His first wife filed for divorce in 2012, the same year Kelley was court-martialed for the abuse of her and her son. He was remarried in 2014.

Authorities said that he had been fighting with his current wife’s family and had sent threatening texts to his mother-in-law, who sometimes worshipped at the Sutherland Springs church. Among his victims was his wife’s grandmother.

“There was a domestic situation going on within the family and the in-laws,” said Freeman Martin, a regional director of the Texas Department of Public Safety.

In some ways, Kelley’s profile is not that unusual. In the U.S., most mass shootings involve domestic violence, according to research from Everytown for Gun Safety, although many incidents do not make national news.

In 54 percent of mass shootings from 2009 to 2016 ― defined as incidents in which four or more people were fatally shot, not including the perpetrator ― the gunman shot a current or former intimate partner or family member. Everytown also found that in nearly half of these cases, the killer exhibited warning signs, such as recent acts of violence, threats or violation of a protective order.

The more than 20 families that lost loved ones will be compensated for funeral costs through a state crime victims compensation fund, Wilson County District Attorney Audrey Louis said Tuesday. A local funeral company has also agreed to donate caskets for all victims.

“We’re grateful for that person and the service to our community,” Louis said of the donations. “People here are concerned with the initial burden, as we all are.”

This article has been updated to include reports about Kelley’s previous threatening behavior, statistics on mass shootings, and details on the gunman’s weapon and ammunition.