[VersionControl] Reset query run if exception is thrown.

Closes #639.