-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queue jobs executed in CLI does not persist repository changes unless executed isolated #44
Comments
@sorenmalling Thanks for this contribution but I'm not sure if it should be in the responsibility of the JobQueue package to persist unrelated changes. $transfer = new Transfer(...);
$this->transferRepository->add($transfer);
$this->persistenceManager->persistAll(); yourself? |
..But I guess we should maybe improve the README in that regard, seems to be a common pitfall |
What is unrelated in this situation? The persistAll is called, only after a The issue in behavior is, that do I enable |
/me updated the description accordingly |
Unrelated to the JobQueue implementation. I don't think that that alone is a major issue – no code should rely on the fact that But especially in job queues you usually only want to mark the job done if it has been processed successfully – and you can only tell with immediate persistence. Otherwise you risk loss of information. (somewhat controversial) final speech: In general I would not suggest this pattern of deferred persistence at all and I think it has been the main source of confusion and bugs with Flow. But obviously I don't want to block this feature if others think it's helpful. So I'll remove my -1 and shall shout "I told you so" in a few years 😄 |
But isn't this (running the jobqueue) done in it's own request with it's own instance of the persistence manager, that will not persist other stuff? Like when i do a request to any other of my controller->action combinations? Alternative suggestion could be to run everyting isolated - that will remove a different experience depending on a option setting (and introduce the persistence as known from other CLI job) |
Not necessarily. But what about the whole deferred persistence / lost information topic – don't you agree to that? |
Purely looking at the code, I can agree. But looking at how the jobmanager is being executed as CLI, I see a behavior that does not match normal CLI scripts. That is why I raise the concern. I found a solution in running isolated (see my reply above) and suggest that everything is being run as isolated to have the same expectation regarding persistence. |
Okay, now I get the root issue. Basically the persistence behaviour is totally different between "isolated" (does auto-persistence) and "non-isolated" (no auto-persistence) execution. That is something that should indeed be tackled. But maybe the PS: Also note, that the automatic persistence after |
@albe You're right - my original issue and pr tried to describe and solve a issue on one go :) I can not, from reading the code, see any issue in running all jobs isoated. And we ensure what was originally the discovered issue:
Win win :-) |
Behavior
I'm having a job with a
execute()
method like thisThe new transfer object is not persisted to the database table when the message is finished
Expected behavior
Similar to other CLI command, I expected the new
$transfer
object to be persistedProposed change
Have a signal/slot that call the
persistAll
on the persistenceManager once amessageFinished
signal is sentThe text was updated successfully, but these errors were encountered: