Fix issues with *Execution entities updates during step execution. Refre...

## Fix issues with *Execution entities updates during step execution. Refresh entity state when EM is reopened after fail

It solves following things:
 - SQL errors on PostgreSQL due to reserved keyword
 - Avoid timeout of connection that used for logging of execution process. 

2nd point usually cause errors like "Entity manager is closed", but actually it was another SQL exception f.e. "Mysql has gone away"  due to inactivity 
In fact, this max_allowed_packet is only linked to the previous version of
the batch bundle (certainly the one you used). Same for the wait_timeout.

In the previous version, we used to only update the stepExecution at the
end of the step. So, it could take a long time with no activity between
connection opening (beginning of the job) and updating the stepExecution.
So you could reach the wait_timeout of MySQL. Moreover, in case of errors
or warnings, all errors and warnings used to be saved in one big bunch,
because saved at the end of the step.

Now that we saved at each batch (see
https://github.com/akeneo/BatchBundle/blob/master/Step/ItemStep.php#L211),
we don't have the wait_timeout problem anymore in the current version of
the BatchBundle.

For the max_allowed_packet, we used to store all the stepExecution errors
and warnings into one big field. Now, all warning is identified by a
warning Entity
https://github.com/akeneo/BatchBundle/blob/master/Entity/Warning.php
with a relation with the stepExecution:
https://github.com/akeneo/BatchBundle/blob/master/Entity/StepExecution.php#L141

So the max_allowed_packet is not a problem anymore as each entity is quite
small instead of having one big entity with all the warnings inside.

So the suggested changes to avoid EntityManager closed and problem with the
max_allowed_packet are not needed for the current version.

Benoit Jacquemont
CTO - Akeneo
www.akeneo.com
Phone: +33 9 83 82 12 73
Skype: benoit.jacquemont


On Tue, Dec 9, 2014 at 1:56 PM, Alexander Smaga <notifications@github.com>
wrote:

> In Entity/JobExecution.php
> <https://github.com/akeneo/BatchBundle/pull/38#discussion-diff-21525817>:
>
> > @@ -62,7 +62,7 @@ class JobExecution
> >      /**
> >       * @var string|null The user who launched the job
> >       *
> > -     * @ORM\Column(name="user", type="string", nullable=true)
> > +     * @ORM\Column(name="`user`", type="string", nullable=true)
>
> It's not only related to wait_timeout also for large execution logs we
> met max_allowed_packet limit exceed, but again error that we saw is Entity
> manager is closed
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/akeneo/BatchBundle/pull/38/files#r21525817>.
>