raft: move defer after run