I hope others contribute to this thread. Discussions about mental preparation & strategy in racing are interesting.
A runner told me to try this mental approach when dealing with the “hurt” in racing. Acknowledge whatever discomfort you're experiencing & accept it rather then try to block or ignore the negative feelings. I zone in on what I'm feeling whether it's lungs or legs, tell myself yes, this hurts but I'm going to be o.k. with it, I can deal with this.
I've practiced it for a few years & it's worked well for me.
I've also done the pick up the pace idea Ryan suggested, just a change in stride can improve how you feel.
Also, post race it feels so much better knowing you didn't back down.