.... if in a sync service task I inserted some data into a DB (non-transactional maybe) and the engine crashes between this point and the next wait state then on resume this data will get inserted in the DB again.
One way of handling this is to place some logic before saving your data in order to check whether it actually needs to be saved or not.
For example from your business logic i.e. do i have an entry for this entity with this id already? etc if it is not possible to have it from your logic then use the process instance id i.e. save the pid in a table associated to the specific entry.
However the same problem you mention may happen at any point of your code as long as it does not belong to the same transaction, so having a way to force saving the state is the same as saving it from the process.
Please take a look at the following discussion, it is a little long but i think this issue is discussed quite thorougly,
Thanks Chris. This info is was what I was looking for.