Fix race condition in reusable statements
From the main commit:
This function used to operate 100% on readonly data, so could be safely used from multiple threads. This is however no longer true since commit af97cede, which might result in TrackerSparql churning again to re-parse the SPARQL into SQL. Moreover, as this was not an atomic operation (far from it), the same TrackerSparql could trigger independently this re-parsing, or surprise older users with data going down their feet. This could produce anything from wrong results, to invalid reads/writes, to crashes. Protect the whole thing with a mutex, so it is ensured it's only rebuilt in one thread, and other users don't get surprised by it.
It's likely to be a source for some of the weird things we were seeing on CI.