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

Rerunning duplicate_task can cause duplicates #81

Closed
dmitriim opened this issue Aug 29, 2023 · 4 comments · Fixed by #90
Closed

Rerunning duplicate_task can cause duplicates #81

dmitriim opened this issue Aug 29, 2023 · 4 comments · Fixed by #90

Comments

@dmitriim
Copy link

Currently duplicate_task grabs a list of modules to be duplicated and then backs them up and restore one by one.

If you have 100 modules to duplicate and process 99, but the last one fails (throw any exception for any reason), then whole task is marked as failed and will be rerun again after 'fail delay' period.

So next time all 99 modules will be restored again and if it fails again, it will restart again and again and so on.

From my point of view there are few way this can be improved:

  1. The easiest way is never restart the task if it fails. That will leave us with only some modules being restored. It won't create any duplicates. The extra option for this one can be to not fail whole task if one activity failed. So catch the error, log it and then move on.
  2. Track completed and failed modules, then retry only those failed. This will however mess with the order of activities.
  3. Clean up after it fails and then rerun the original task. So in this case on fail we will try to delete all just created modules. But it's not guaranteed that the clean up will succeed. As it potentially can also fail.

The down side of any way we pick is lack of feedback for a user so it's not really clear what's happening without looking through logs and etc.

@PhMemmel
Copy link
Collaborator

Thank you @dmitriim for reporting this issue. I agree that this is not ideal.

What solution do you personally prefer? Personally, I probably would go for the following (which is your option 1):

  • If a course module duplication fails, catch the exception, log it, and continue the job.
  • Though it is not very clean, I would let the job finish and mark itself as successful (although technically it was not completely) to avoid a rescheduling of the task.
  • User feedback still missing in this scenario, but I do not have an idea on how to deal with that without writing really a lot of code which probably is not worth.

Option 2: I'd rather not choose this, because if one duplication fails it is very likely that this is not a temporary issue, but there are some inconsistencies or sth else, so an admin or developer has to deal with this.
Option 3: See option 2.

@dmitriim
Copy link
Author

Hi @PhMemmel

Agree. Option 1 is the best in that case. I'd suggest logging errors using events API so we can provide some sort of feedback via events (could be seen in Moodle logs) or potentially configure tools like tool_trigger to notify a user via email.

TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 12, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 13, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 13, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 13, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 16, 2023
@TomoTsuyuki
Copy link

I made PR #90 for this issue.
Please review and merge if it's ok.

TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 22, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 24, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 24, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 24, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 24, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 25, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 25, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 25, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Oct 25, 2023
@TomoTsuyuki
Copy link

I made PR for 401 branch

For master #90
For 4.1 #97

TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Nov 21, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Nov 21, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Nov 21, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Nov 21, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Nov 21, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Nov 21, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Nov 21, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Nov 21, 2023
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
TomoTsuyuki added a commit to TomoTsuyuki/moodle-block_massaction that referenced this issue Jan 11, 2024
Syxton pushed a commit that referenced this issue Jan 11, 2024
* Update ci.yml

* Issue #81 No failure during duplicate and write error into event

* Issue #81 Add fail event and support duplicate to another course

* Issue #81 Refactor error event trigger
Syxton pushed a commit that referenced this issue Jan 11, 2024
* Issue #81 No failure during duplicate and write error into event

* Issue #81 Add fail event and support duplicate to another course

* Issue #81 Refactor error event trigger
Syxton pushed a commit that referenced this issue Dec 16, 2024
* Update ci.yml

* Issue #81 No failure during duplicate and write error into event

* Issue #81 Add fail event and support duplicate to another course

* Issue #81 Refactor error event trigger
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

Successfully merging a pull request may close this issue.

3 participants