Fix for #2907, labels on varlength patterns where not checked properly.
Make type rules in Add clearer

Taken from #3235
Merge pull request #3245 from cleishm/type_clearup

[2.0] Make type rules in Add clearer
Single thread pulling updates on HA machines

Moving from an HA communication design where updates gets streamed from
the master on most individual requests coming from slaves. This design
caused lots of duplicate transactions being streamed from master to each
slave, specifically if slaves issued write requests to the master.

Moving to a design where slave communication with its master does not
stream back transactions, except when doing store copy. Instead master
returns a transaction obligation saying which transaction id that must be
applied in order to continue. The slave will notify the single update
puller about that and will in turn be notified by the update puller
when that transaction has been applied. Many requests can poke the update
puller simultaneously and transaction pulling will piggy back on each
other, since there's only one thread pulling.

Benefits include:
- No code explicitly dealing with and preventing pull storms
- Less network communication with master
- Less load put on master
- Possibility for more optimizations regarding applying updates on slaves
  since updates are pulled in a single thread only.
Removed unnecessary TxIdGenerator abstraction
Slaves applies transactions from master in batches

by having a specific TransactionAppender that doesn't do auto-forcing.
And since there's only one thread on each slave receiving transactions
from its master they are queued and applied in one go now and then like:

- append all queued transactions to log
- force log
- apply all queued transactions to store
Merge pull request #3240 from pontusmelke/issue-2907

[2.0] Fix for #2907, labels on varlength patterns where not checked properly.
Merge remote-tracking branch 'upstream/2.0-maint' into 2.1-maint
Merge branch '2.1-maint'

Conflicts:
	community/cypher/cypher/src/test/scala/org/neo4j/cypher/MatchAcceptanceTest.scala
Deleted nodes includes deleted dynamic label records

If a node that got deleted had dynamic label records they weren't
included in the "after" state of a node record, which means they wouldn't
be deleted when applying that node command on the store. Later on such
dynamic records would be viewed as inconsistencies since their owner was
not in use anymore.

This issue was recently introduced where some amount of cleverness was
removed from the store applier, cleverness including looking at
before/after start and merging the two, infering which records should be
deleted.

Now when writing a node record its dynamic records are always written to
the log, and always read back when reading from the log. Also when
deleting a node simply mark all dynamic label records as not in use
instead of clearing the list on the node record itself. This go hand in
hand with what is done around dynamic records in property records.
Splits UpdatePuller into two roles: obligation fulfiller and update puller
Merge pull request #3236 from tinwelint/2.2-single-update-puller

[2.2] single update puller in HA
Merge pull request #3201 from tinwelint/2.2-del-dyn-label-records-w-del-node

[2.2] Deleted nodes includes deleted dynamic label records
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