FBI Director James B. Comey on July 8. (Carolyn Kaster/Associated Press)

AS THE country has been jolted from mass shooting to mass shooting, the gun control debate has become depressingly routine. Advocates of tighter restrictions on firearms invariably call for better background checks, banning large­capacity magazines and other measures that would make gun deaths less likely. Gun zealots answer that even the most common-sense reforms aren’t relevant because they wouldn’t have prevented the mass shootings that keep horrifying the nation. The forces of “no” keep Congress from acting.

On Friday, FBI Director James B. Comey offered a revelation that casts new light on that impasse. Dylann Roof, Mr. Comey told reporters, should have failed a federal background check. The 21-year-old racist admitted to illegal narcotics possession in February, which should have prevented him from purchasing a firearm. Instead, Mr. Roof bought the .45-caliber pistol allegedly used in the attack on Charleston’s Emanuel African Methodist Episcopal Church from a South Carolina gun store without setting off alarm bells. Bureaucratic wires between South Carolina and Washington got crossed, and a federal analyst didn’t see Mr. Roof’s admission.

Mr. Comey’s revelation should, first, inspire a lot of soul-searching among federal law enforcement. They aren’t responsible for Mr. Roof’s virulent racism, but they failed in the narrow area of responsibility that the nation entrusted to them. Congress has stifled the study of gun violence and the enforcement of gun laws in the past. But this appears to be a the fault of a poorly operating database.

Mr. Comey’s admission should also drive home what should be an obvious point: A tightened, functional background-check system and other simple measures would erect real and practical barriers to people attempting to buy guns for nefarious purposes. If the system had worked correctly in this case, Mr. Roof would have been turned away at the gun store counter. If Congress had tightened up the system’s rules years ago, he would have had a harder time looking elsewhere, such as at gun shows. If federal and state lawmakers weren’t so in thrall to the pro-gun fringe, friends, family members and other potential sources would have faced clear and high penalties for giving Mr. Roof a weapon without taking him to a gun store to get checked out first.

It’s entirely appropriate to talk about imposing basic gun laws in the wake of any mass shooting. All of them underline the fact that guns are shockingly efficient killing machines that no responsible government would ignore. Even if better gun laws wouldn’t prevent every rampage or end street crime, they would certainly cut down on gun deaths from all sorts of causes by making it tougher to obtain and use firearms illegally.

But in the case of Mr. Roof, gun activists now can’t easily fall back on the argument that better gun laws couldn’t have helped. Maybe Mr. Roof would have been so determined to start a race war that he would have eventually found a gun. Maybe not. What’s clear is that it didn’t have to be so simple for him. The country should have tried harder to stop him — and should be trying harder to stop the other Dylann Roofs still out there. That means law enforcement can’t be asleep at the switch. And it means that Congress should finally pass more common-sense gun limits that would make it harder to skirt the system.