NYPD Sgt. Hugh Barry’s murder trial begins Tuesday, guaranteed to reopen the city’s racial wounds.

Barry, who is white, fatally shot Deborah Danner, 66, an emotionally disturbed black woman, in her Bronx apartment. Police say she swung a baseball bat at him.

Also on trial of another sort will be Commissioner James O’Neill and Mayor Bill de Blasio — not for criminal wrongdoing, but for publicly prejudging the case.

“We failed,” O’Neill said the morning after the Oct. 18, 2016, shooting. He added that Barry had not followed procedure because he didn’t use his stun gun or call specially trained detectives from the Emergency Service Unit. The mayor, displaying his subliminal police bias, said, “Deborah Danner should be alive right now. Period.”

Last June, Bronx District Attorney Darcel Clark said a grand jury had indicted Barry on charges of second-degree murder, first- and second-degree manslaughter and criminally negligent homicide. Second-degree murder means intentional murder, and appears to be an overcharge. Under state law, police officers can use deadly force if they feel their lives are threatened.

At the same time, the judicial system has a way of protecting cops in such circumstances — notably in the Bronx.

It did so in the case of Stephen Sullivan, the white cop who fatally shot Eleanor Bumpurs, an emotionally disturbed black woman, during an eviction procedure in 1984 after police said she charged them with a knife.

It did so in the case of Frank Livoti, who put a chokehold on Anthony Baez in 1994, which led to his death.

It did so in the case of the four cops who fatally shot Amadou Diallo. He was standing in the vestibule of his apartment building in 1999 when a passing cop mistook his wallet for a gun.

In all three cases, cops waived their right to a jury trial, fearing so-called anti-police bias of Bronx juries. Instead, they opted to be tried by judges. In all cases, the cops were acquitted, though Livoti was later convicted in federal court of violating Baez’s civil rights.

Barry has opted to be tried by a judge — Robert Neary, a longtime Westchester prosecutor and judge who now sits in the Bronx. Colleagues described Neary to NYPD Confidential as a “law-and-order, pro-cop” judge who is “reasonable.”