If the process dies during wal.cut(), it might leave a corrupted wal file. This commit solves the problem by creating a temp wal file first, then atomically rename it to a wal file when we are sure it is vaild.