FoundationDB/sql-layer — pull request #1354 by tjoneslo (2014-07-04 15:28:01+00:00)
Title: Index statistics snapshot read

Make the read of the IndexStatistics from the database table into the histograms data structure use a snapshot read, rather than concurrent one.

The problem before was a user would open a transaction, start a query, the optimizer try and read the index statistics and finding there were none, trigger the background task to create them. The query processing starts to execute. In the mean time the background index statistics thread writes into the IndexStatistics table. Then the query tries to commit, and the index statistics read part of the transaction encounters a read/write conflict and aborts the transaction (unnecessarily).

The fix has the initial index statistics read use a snapshot read. The background write no longer generates a read-write conflict. everyone is happy.

The tests needed an update because it is no longer possible to write the index statistics and read them back in the same transaction. So the two index statistics tests need to be split into two transactions. One to write, one to read.