Add a mutex for the db connection. Fixes #14500

Assuming sqlite is compiled in multithreading mode (see http://www.sqlite.org/threadsafe.html ) then we at least need to protect the database instance.