I have had big dogs for over sixty years, my biggest dog right now is 6'1" on his hind legs and over 200 lbs. He is as sweet a dog as you've ever met. We also have two regular sized retrievers who of course are also as sweet as they come. That said, one rule of dog ownership is, no matter how careful you are or how well fenced your yard is, eventually

will happen and your dog(s) will get out. I have never had a mean or aggressive dog so, when my dogs have gotten out over the years, they normally show up at a neighbors house looking for snacks or go for a swim in their pool (retrievers are irrepressible when it comes to any body of water).
I have experienced other dogs getting out and and trying to attack my dogs, even small dogs will act aggressively towards much bigger dogs. One recent incident saw a small, yappy dog get out and chase after us and my 200 lbs. dog pulled his leash right out of my hand (and I am bigger than he is) and he chased the yappy dog right back home, then he turned around and sauntered back to us with a somewhat smarmy expression of satisfaction on his face, pretty funny in retrospect.
I've also had dogs get out and literally attack both myself and my dogs (different incidents) so, when we are walking the dogs in unfamiliar neighborhoods, I carry a graphite tennis racquet, I learned at dog beach that a tennis racquet is GREAT for separating dogs without being bitten, it's also great for whacking the attacking dog without hurting them but, it does startle them and frequently ends the confrontation. Another trick is to grab the attacking dog by the tail and pull them away, NEVER, EVER grab one of the dogs by the collar or anywhere near their faces, you will be bitten, a lesson I have personally learned.
Other things work as well, make yourself as big and loud as possible before the other dog gets to you, yell at them to go home, stomp your feet, throw rocks, grab and use a branch or anything else that is handy to deter the attacking dog. The last thing you want to do is runaway unless you can get behind someone's fence or gate before the dog gets to you because dogs instinctively chase anything that runs.
Of course bear spray is another great option, much better that typical pepper spray as it will spray much further and with greater volume.
Last thing I would do is shoot someone's dog, I would discharge a weapon into a tree or the dirt in the hopes the report would scare the animal but, if all else failed and if my dogs were being injured or my wife and or I were being threatened, I would shoot the attacking dog. I would also hope no one witnessed the event and I would probably make the attacking dog's carcass disappear. Yes, not entirely legal or ethical but that's what I would do. I would also go home and document the entire event.