I've only had one dog that ever caused me to really be afraid. I squirted him (her?) with the water bottle, but that didn't work. The SOB was biting at me no matter what, and I could not sprint away (he was FAST) from him. I tried a few sprints, but the dog was in better shape than me! At that time, I carried a Silca frame pump, but didn't want to strike the dog.
So I had to dismount and keep the bike between me & him and I was yelling at him, "NO!" as he was trying to get at me. He kept trying to come around one side or the other and I just had to keep turning and keep the bike between us. Eventually, he tired out and trotted off, back home presumably. By the time he trotted off, I was pretty shaken and tired and my heart was still in my throat.
I never knew who's dog it was, as he kind of appeared out of nowhere, but I avoided that street for a LONG time after that encounter.