Fix for race with commit updating the cache.

Extends the range of the locks acquired while writing to the store, to a
greater region including the place where we update the cache. Also make
sure we acquire corresponding read locks when attempting to read
relationships into the cache for a node.

This should be deadlock free because reader threads only ever acquire
a lock for one node at a time, and release it immediately after updating
that node. And while the writer thread acquires multiple locks, we only
ever have one writer thread acquiring locks at any given time.