Fix record deletion condition error in deleteinvalidconfiglog task - #3399
Open
Lai Wei (weilai-irl) wants to merge 3 commits into
Open
Fix record deletion condition error in deleteinvalidconfiglog task#3399Lai Wei (weilai-irl) wants to merge 3 commits into
Lai Wei (weilai-irl) wants to merge 3 commits into
Conversation
The config_log deletion was nested inside the "if (!empty($logidstodelete))" block, so the records were only removed when a matching record still existed in logstore_standard_log. That match is not guaranteed: old log records are removed every night by \logstore_standard\task\cleanup_task according to the loglifetime setting, while config_log is never purged by Moodle. When no match is found nothing is deleted, the task then counts the records again, sees they are still there and queues another adhoc task, which reads the same records and repeats. Close the block after the logstore deletion so the config_log records are always deleted. The execution time check and the pause between chunks move out of the block as well, so they apply to every chunk.
$totaldeleted only counted logstore_standard_log rows deleted, so the "Processed X records so far" message logged on hitting the execution time limit stayed at 0 whenever a chunk had config_log rows with no matching logstore_standard_log row - the common case this fix targets, since old log entries are routinely purged by \logstore_standard\task\cleanup_task while config_log is not. Count config_log deletions too so the progress message reflects actual work done.
There was a problem hiding this comment.
Pull request overview
Fixes the local_o365 ad-hoc cleanup task so it removes config_log rows even when the corresponding logstore_standard_log rows no longer exist (e.g., already purged by Moodle’s standard log cleanup), preventing the task from repeatedly re-queuing without making progress.
Changes:
- Ensures
config_logrecords are deleted for each processed chunk regardless of whether any matchinglogstore_standard_logrows are found. - Updates the in-code rationale to explain why a logstore match is not guaranteed (standard log retention/cleanup vs.
config_logretention).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Review feedback on the time-limit mtrace message noted that $totaldeleted combined logstore_standard_log and config_log deletion counts, making "Processed X records" ambiguous about which table it refers to. Split it into $totalconfigdeleted and $totallogstoredeleted, and report both in the message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix local_o365 adhoc task deleting config_log records only when a matching logstore_standard_log row exists, causing infinite requeueing