Fix a few potential deadlocks in cdr_sqlite3_custom.