ON CONFLICT and exclusion: let the constraint settle the race
Checking first and inserting second loses to the request that arrives in between. Insert or update in one statement, and refuse overlapping bookings with a constraint that compares ranges.
Checking your access…