I haven't been able to reproduce with SQLite. The backend in which the issue was seen is PostgeSQL.
The duplicate key violation must have been due to a duplicate field value (e.g. _comment1). I could only see that happening due to a second submit before the database transaction of the first submit has been committed. Therefore I'll add the trac-disable-on-submit class to the submit button (#10138).