Fix database connection timeout bug