When priests were serving at the Jerusalem temple, and they had to go to the toilet, what could they do? Weren't they required to remain on site? This could have been a pressing issue.

I was wondering about this myself just a few weeks ago. (Really! Exod 8:35 got me thinking... When the priest was ordained, he couldn't leave the temple precinct for a whole week.) Then yesterday I came across a helpful article in the Journal of Biblical Literature (142, no.1 [2023]). The answer is found in the Mishnah, which I read back in the '90s, but must have forgotten the memorable passage. Fortunately for the priests, there was an underground toilet:

If one of them suffered a pollution he would go out and go along the passage that leads below the Temple building, where lamps were burning here and there, until he reached the Chamber of Immersion. There was a fire there and a privy, and this was its seemly use: if he found it locked he knew that someone was there; if open he knew that no one was there (m. Tamid 1:1; also b. Šabb. 25b; b. San. 17b).

So... no agony, ruptured bladders, or impacted colons. The Lord provides.