Fix race condition in sparql querying