Resolve two race conditions relating to HA lock sessions

- Adds a check ensuring a slave commit has a running lock session when committing,
  or has explicitly opted out from having one.

- Moves lock session management into its own class, where timeouts and concurrent
  access can be tested in isolation.
Revert the change which adds count values in the state on read

- it is indeed better to delegate the caching to the page cache used in the CountStore
- having less values in the in-memory state will also make the sorting much faster when we need to merge them
  with the one on disk
Increase key-value record size to 16 + 16 bytes

- change node and relationship key encoding to write a type byte
- extract CountsStoreWriter and added tests
- fix a bug in the binary search when reading entries ordered by key
Stop visiting records when reading an empty one from the page
Add tests for CountsStore
Extract record serialization outside the CountsStore

Now the CountsStore accept generic keys
Change CountsStore.get to accept a register rather than returining a long
Make the counts store generic on values type
CountsStore takes a WriterFactory rather than creating a specific CountsStoreWriter
Repackaging to separate the concepts of KVStore and CountsStore

- revisit KeyValueRecordVisitor to be generic
- the specific CountsStore visitors uses registers rather than passing aroung longs
Rollback to assuming dependence between predicates
Change the abstraction used for switching cardinality models

 * Instead of using SelectivityCombiner as the abstraction that
   is used to switch between different models,
   QueryGraphCardinalityModel is now the abstraction to use
Added assumeIndependence cardinality model
Added exponential backoff as a selectivity combination strategy
Changes communication between appender and forcer in batched writes

to only rely on appender ticket and force ticket, w/o even involving last
committed transaction id, which was an unncessary involvement.
Also added tests to absolutely make sure that appender waits for correct
round of force, even in the face of ticket long values wrapping around
Long.MAX_VALUE.
Change cardinality estimation to assume independence between predicates
Fixed the serialization of PlanDescription.

Prior to this fix, DbHits, Rows, EstimatedRows and IntroducedIdentifier were not serialized
correctly, e.g. DbHits(5) was serialized as "DbHits(5)" instead of just "5". The child plan descriptions
were also incorrectly handled and has been adressed by this fix.
Merge pull request #3264 from tinwelint/2.2-correct-batch-force

[2.2] Changes communication between appender and forcer in batched writes
Fixed issue with input iterator starting too soon

CalculateDenseNodeStage was set up before executing NodeStage, accepting
an iterator of InputRelationship. Calculating the dense node count might
depend on IdMapper to be prepared. IdMapper was prepared after NodeStage
was done. Problem was that the Input used in this test wrapped the
iterator in a resource iterator that retrieved its first item in the
constructor and so made the first InputRelationship pick invalid node ids.

Effect of this would be that the node degree would be off by one for a
select few nodes.

Fixed by using PrefetchingResourceIterator instead which fetches in
hasNext, which is expected in most places.
Merge pull request #3268 from systay/cardinality-refactor

[2.2] Cardinality refactor