Our boxer Harry had this happen about a year ago.He was put on antibiotics which cleared the problem,but then it came back again a month or so later and after a second time on antibiotics he had to have his anal glands removed as they were damaged and would have kept getting blocked/infected.The operation was quite traumatic but he healed and he hasnt had a problem since.The vet did say it could be cancer but after the operation it was confirmed as a bad case of impacted glands which had to be removed.Most dogs clear up after antibiotics apparently so hopefully this happens for you.