Do not commit task.session, the framework manages that

You can create your own session if this data absolutely needs to be persisted even if the task fails (and does database rollback)