fix some db handle bug,optimize database transaction control