Dylann Roof got the pistol he used to kill nine people in a historic black church in South Carolina without a completed background check because of gaps in FBI databases, legal restrictions on how long the FBI can keep data on gun purchasers and other breakdowns in the system, according to an internal report obtained by CQ Roll Call.

Four years after the 2015 attack at the Emanuel African Methodist Episcopal Church in Charleston — and several more high-profile mass shootings — a bipartisan group of senators is still trying to hammer out a deal with the White House on background check legislation.

[Justice Department slow to answer Congress on gun background checks]

Roof, an avowed white supremacist with a history of drug use, obtained a .45-caliber Glock pistol despite a drug arrest that should have blocked the purchase. The FBI began a review of how that happened not long after the shooting.

Recommendations in that 2015 report by the FBI’s Inspection Division included expanding what databases the bureau used for background checks, updating how it requested records from local law enforcement agencies and revising strict internal protocols that the report said hamstrung the process.