There is no limit on how long a dog can abstain from intercourse. It can cause some frustration, especially in spring time during the natural mating season, but as far as I know there are no negative health impacts. The macho behavior during mating season is more likely caused by hormones and not influenced by whether or not the dog mates.
In fact, if dogs (formerly domesticated, wild dogs or wolves) live in a wild environment without human interference, only the alpha male and alpha female mate and breed. They will actively punish any other male who tries mating. Male offspring is cast out of the pack when they mature. Those who don't join a new pack and cannot sneak in a secret rendezvous with a female of a rivaling pack never have the chance to mate in their life.
The supression of mating behavior was observed in several studies, one of which is 249576166_Male_and_Female_Mating_Competition_in_Wolves_Female_Suppression_Vs_Male_Intervention/amp
[...] the authors observed an increase in general aggression and in the frequency of interventions during the mating season. Separative interventions were observed predominantly in males and were directed against male-female sexual interactions, while such interventions by females were less apparent. Males showed a high frequency of intrasexual aggression but only during the mating season. Females showed less intrasexual aggression, and instead, showed a high level of intrasexual dominance display, especially the alpha-female, and they did so both in and outside the mating season.