Some 2.8 billion gallons of untreated wastewater — including raw sewage — is pouring into Bay State rivers and streams annually during heavy rainfall, state records show.

One severe trouble spot is the Merrimack River, where the problem threatens progress from decades of work to clean up what was once declared among the nation’s Top 10 dirtiest waterways.

“In 2017, I’m shocked that the levels of contamination in the outflows, and the amount of raw sewage flowing into the river is still at the magnitude it’s at,” said Amesbury Mayor Kenneth Gray.

A Halloween weekend storm dumped 8 million gallons of wastewater into the Merrimack when power was knocked out to the Lawrence treatment plant, where there is no backup generator.

Next door in Lowell, records obtained by the Herald show, nearly 32 million gallons of untreated wastewater also roared into the river during the same storm because the volume overwhelmed the filtration system.

The EPA passed the Clean Water Act back in 1972, and local government officials and clean-water advocates say they can’t believe they’re still talking about human waste in the river.

“What’s going into the river is stuff that comes out of your toilet,” said Rusty Russell of the Merrimack River Watershed Association. “There are essentially six different city sewage systems dumping raw sewage into the Merrimack River whenever we have a moderate to heavy rainstorm.”

The Merrimack is used as a public drinking water supply for Lowell, Lawrence, Methuen and Tewksbury. Billerica draws its drinking water from the Concord River, a tributary of the Merrimack. Other communities along the 117-mile river use it for boating and recreation.

But fixing outdated pipes, building standby tanks and other plant upgrades has proven to be far too expensive for towns along the river.

The EPA has cut deals with the plants for lengthy schedules, but the price tags are still hefty. From 2003 to 2013, the Lowell Regional Wastewater Utility Plant spent $120 million updating its system. It will cost another $52 million to meet EPA standards next year.

But it’s still not enough.

“We need federal money,” said Mark Young, head of the Lowell plant. “However high it is, senators and representatives, we need big federal dollars.”

Young said when it rains, the city often has no alternative but to open the spigot and let the raw sewage race into the river. But, as his counterpart in Lawrence has said, the racing river carries the pollution out to sea.

State Sen. Kathleen O’Connor Ives, whose First Essex Senate District runs along the Merrimack River, said it’s time to start caring about the waterway again.

“This is an issue that’s truly under the radar, unfortunately,” she said. “Whether they’re drinking it or not, they’re certainly bathing in it, their dogs are in it.

“I think that people take for granted that this is Massachusetts … we’re not dumping raw sewage, untreated sewage into our own rivers where we boat and kayak, and recreate. But in fact it is what’s happening,” she said. “It just takes a stormy, rainy day and there’s raw sewage in the river.”