Transactional entities? I'm working on a custom Drupal 8 module. In a form submit function, I need to create several entities of different types. I am worried about what will happen if something goes wrong in the middle of the operation, as it will be difficult to clean up the mess.

So my question is: is there any kind of transactional mechanism for entities, similar to SQL transactions, so that I could conveniently rollback in case of an error?

If not, what strategy would you suggest?
You can wrap all the entity save calls in a further transaction with Connection::startTransaction for a given database connection. Inject the database service into the form using FormBase::create

Catch using DatabaseExceptionWrapper and rollback :-). This is similar to Drupal 7 behavior as well.

It would be best to provide a unique name for the transaction as the transaction stack is fairly basic.