Normally, when a dog poops, the fluid in his anal sacs is squeezed out, too. Your vet will open and drain the abscess and usually prescribe.
Treatment for impaction involves expressing or emptying the sacs. bloody and eventually the sacs become filled with pus, forming an anal sac abscess.
Anal gland impaction in dogs: treatment & prevention. Anal impacted or, even worse, infected - a very painful condition requiring urgent veterinary treatment.