fixed the database deadlock bug