Investors are growing anxious about the war’s duration and its impact on energy markets as oil extends sharp gains.