I've seen moderators of small communities hold off the effect by setting a good example, using a deft touch, and not letting the community get too big.
My suspicion is that once the number of commenters gets much past Dunbar's number [1], the universal fall into "default jerk" happens. Once that's taken place, you're stuck in an Eternal September.
Communities in the real world don't scale well. I'm not sure why programmers expect them to on the Internet, with its well-known capacity for dehumanization.
And perhaps make it so that DOWNVOTES CAN BE DOWNVOTED (provided a written reason is given for that as well).
I think they don't have enough (or any?) moderators working for them. They rely too much on making profits with the free help of trolls.
I understand it would be hard for them to change the power of the troll-users by now. Perhaps we simply need a new Stack Overflow, some competition.
I don't really have an answer to the problem, SO has some very smart people working for them who, I'm sure, think about this issue. For some reason technical discussions held by competent people on the internet seem to trend towards dumpster fire. I've also noticed this phenomenon on photography discussion groups.