fix bug for database transaction and add comments for some api in it.