Honestly, I couldn't find any scientific studies on the matter.
That being said, I would recommend not drinking fluids more than 2 hours before bed. If you drink caffeine this even exacerbates the problem since caffeine is a diuretic (makes you lose water) and a stimulant. Getting up to go to the bathroom, especially if you are in an insomnia rut, can keep you in that pattern with a lot of negative reinforcement.
Even if it is uncomfortable, unless you have another medical condition, I would consider trying this for at least a week to see if you can decrease waking up at least one less time.