Attached v02, rebased on latest master. It uses the new nbtree lock/unlock functions by Peter and I’ve verified with Valgrind there’s no cases where it’s trying to access pages without holding the lock. Just for debugging, I ran the Valgrind session on a modified version of the patch that always favors a skip scan over a regular index scan, in order to greatly increase the Valgrind coverage of the new parts.