Thanks Tom.
The version of Postgres is: 9.4.7
The UI application is to add/remove some permissions through a listbox for a certain user. For any add/remove, it will first delete all records for this certain user in the table, then insert the values chose from UI.
In my code snippet, it first execute the DELETE, then execute multiple INSERT to insert selected options into the table. After all done, commit.
The server is in remote and I don't have detailed logs at this moment. Will try to ask for that.
My question: for that error 'DefineSavepoint: unexpected state STARTED', not quite sure happens in which step? In the middle of DELETE or INSERT?