How the single-flight pattern can prevent race conditions