Skip to content
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

Schedule task is being repeated if locked #176

Open
maikelreyes opened this issue Aug 29, 2020 · 6 comments
Open

Schedule task is being repeated if locked #176

maikelreyes opened this issue Aug 29, 2020 · 6 comments

Comments

@maikelreyes
Copy link

image
After a recent migration to the last version, if one task is locked, this is being inserted again in the task list (screenshot attached)

Any possible workaround to found this bug/issue?

@alexandersch
Copy link

Got the same issue

@bpastukh
Copy link

same story

@alexandersch
Copy link

I've done a quick fix by setting command as a unique field in the database

@armellin
Copy link

It seems that the entityManager gets confused and tries to INSERT a new row instead of UPDATE'ing the correct one.
Setting "command" as a unique field in the database is NOT the solution: the executeCommand fails with a duplicate key exception, so even if it doesn't mess the database up by creating a new entry, it doesn't unlock the right entry as well.

It seems to work if we retrieve the scheduledCommand instance from the database just before unlocking it:

--- vendor/jmose/command-scheduler-bundle/Command/ExecuteCommand.php.orig	2020-10-21 00:40:33.467171379 +0200
+++ vendor/jmose/command-scheduler-bundle/Command/ExecuteCommand.php	2020-10-21 00:38:22.263744598 +0200
@@ -249,6 +249,7 @@
             $this->em = $this->em->create($this->em->getConnection(), $this->em->getConfiguration());
         }
 
+        $scheduledCommand = $this->em->find(ScheduledCommand::class, $scheduledCommand);
         $scheduledCommand->setLastReturnCode($result);
         $scheduledCommand->setLocked(false);
         $scheduledCommand->setExecuteImmediately(false);

@alexandersch
Copy link

Thanks, I've made a pull request for it #181. Your solution is of course better.

@kovinet
Copy link

kovinet commented Apr 9, 2021

This started happening in my case after I added $this->entityManager->clear(); inside my command which is executed, so this seems related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants