Rhode Island Democratic gubernatorial nominee R.I. General Treasurer Gina Raimondo. (Steven Senne/AP)

SINCE THE RECESSION, some state and local governments have come to terms with massive shortfalls in their pension obligations to retired public-sector employees. Still, the gap between available dollars and projected funds owed to retirees remains huge — more than $1 trillion, according to the Pew Charitable Trusts. And bitter fights continue between unions representing public workers and reformers trying to fix the problem before it cripples state and local budgets.

In some instances, that battle has been waged between factions within the Democratic Party, and nowhere more bitterly than in tiny Rhode Island, which, despite its size, dug itself a gargantuan pit of pension debt over the years with lavish promises and fiscal mismanagement.

In 2010, Gina Raimondo, a young Democrat with experience as a financier but none in politics, ran for state treasurer on a promise to address the issue. She won resoundingly, then swiftly went about fulfilling her pledge. In the face of ferocious opposition from labor, she explained the plain budgetary impossibility of maintaining pensions at the levels promised by politicians in Providence.

Legislation to rein in pensions and set the state on a path to fiscal sanity passed in 2011, mainly as a result of Ms. Raimondo’s tireless advocacy. And on Tuesday, Democratic voters rendered their verdict, choosing her by a wide margin in a three-way primary for the gubernatorial nomination.

Although Rhode Island is heavily Democratic, Ms. Raimondo isn’t governor yet; she’ll face a Republican opponent, Cranston Mayor Allan Fung, on the general election ballot in November.

Nonetheless, her primary victory is an encouraging sign that many voters, including Democrats, have woken up to the peril posed by years of reckless promises by office-holders beholden to public-employee unions. Although she endured vicious attacks from liberals accusing her of anti-labor apostasy, the real issue, she rightly insisted, is not ideology; it’s math.

In Rhode Island’s case, pensions for the state’s 21,000 retired public employees were soaking up 10 cents of every dollar of state tax revenue; that would have risen to 20 cents in just a few years. The state’s pension fund, already underfunded by some $7 billion, was spending more than it took in; it would have been completely broke in 25 years or less.

Many states have tried to deal with pension shortfalls by trimming benefits for the youngest and least senior workers. The legislation advanced by Ms. Raimondo went further, suspending annual cost-of-living increases for retirees and shifting workers to a hybrid system combining traditional pensions with 401(k)-style accounts.

Without those measures, she explained, the state would be forced to make deep cuts to spending on public transit, libraries, aid for the elderly, schools and roads. To do so, she said, would be immoral; the pain had to be shared.

Ms. Raimondo’s primary victory should stiffen the spines of Democrats in other states where taxpayers and the services they count on have been given short shrift in favor of public-sector unions. Presented with the facts, voters can be persuaded to opt for balance and fiscal sanity.