MB-16633 Fix to potential race between reader and writer in syncing a DB header
MB-16633 Fix to potential race between reader and writer in syncing a DB header

The following race can happen between readers and writer in synchronizing
the latest database commit header:

Timestamp 1: reader checks the header revision and confirms that it still
has the up-to-date header h1

Timestamp 2: writer invokes fdb_set_file_header and filemgr_commit
(append header h2), and finally releases all the WAL items from the WAL index

Timestamp 3: The same reader looks up the WAL, but can’t find a WAL entry for
a given key, and tries to look up the main index with the old header h1, but
can’t find the key.

Although the above race can rarely happen as the writer needs to spend much
more time executing the above sequence of operations, it should be addressed
to prevent any kind of potential racing issues.

To fix the above issue, this change adapts the reader to get the latest
header after checking the WAL index.

Change-Id: I3c1ae8cb3bb33855eaa93631776a319cf39db2b6

wurikiji/forestdb,hisundar/forestdb,hisundar/forestdb,couchbase/forestdb,wurikiji/forestdb,couchbase/forestdb