This patch checks b->hash_val before attempting to lock the node in the
btree, which makes it more equivalent to the "lookup in hash table"
path - and potentially avoids an unnecessary transaction restart if
btree_node_mem_ptr(k) no longer points to the node we want.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
if (c->opts.btree_node_mem_ptr_optimization) {
b = btree_node_mem_ptr(k);
- if (b)
+ /*
+ * Check b->hash_val _before_ calling btree_node_lock() - this
+ * might not be the node we want anymore, and trying to lock the
+ * wrong node could cause an unneccessary transaction restart:
+ */
+ if (b && b->hash_val == btree_ptr_hash_val(k))
goto lock_node;
}
retry: