fix assertion failed: hash_table->ref_count >0, add lock to db query