wal: save latest state into new WAL

So we could always read out state when open at valid index.
Merge pull request #1839 from yichengq/245

wal: save latest state into new WAL