A couple thoughts... just because a dog is wagging his tail doesn’t mean he won’t bite you, it just means he’s happy. He may be happy to bite you.
I have pepper sprayed more dogs than I can count (and a few humans). It works, it you have to practice once or twice, and be aware of where the relative wind is coming from.