General help

How Moodle's garbage collection works?

 
Picture of Mohammad khondakar
How Moodle's garbage collection works?
 

Moodle 3.2.1

If delete moodle users ( sitadmin->users->bulk useraction), then user will be deleted from database (mdl_users).
Will it also delete corresponding data from mdl_files ( file path, filename, mimetype etc store here)?
If so then file under moodleData  will become reference-less that means become 'orphan file'. Then cronjob will delete those file. Am I right?

Is that how it works?  If anybody has idea please share?

Thank you.

 
Average of ratings: -
Picture of Leon Stringer
Re: How Moodle's garbage collection works?
Particularly helpful Moodlers

It's a bit more complicated than that.

There are some old posts discussing this (one, two) but essentially the row is kept in mdl_user but marked as deleted (i.e. the deleted column is set to 1), some information is lost at this point -- it's an unrecoverable operation.

User private files would be removed from Moodledata but course files are not. This includes assignment submissions to courses, these become invisible via Moodle but still take up space in Moodledata. They're not orphans though, under the hood there's still a link to the mdl_files entry from the course via the assignment. I think MDL-47265 covers this issue.

So yes mdl_files and Moodledata store individual files once and these are removed from Moodledata when the last reference is removed. But deleting users doesn't necessarily remove references to course activity files such as assignment submissions and these can still take up space (which is a little frustrating).

 
Average of ratings: -
Picture of Mohammad khondakar
Re: How Moodle's garbage collection works?
 

Thank you Leon, great explanation.

 
Average of ratings: -
Picture of Mohammad khondakar
Re: How Moodle's garbage collection works?
 

moodle 3.2.1

Step1:
I made several test course. Enrolled 2 student + 2 teacher in those courses.
Uploaded audio/video files by student and teachers by poodll. Student's audio/video mainly on quiz and forums.

Step2:
Deleted those users by : siteadmin -> Users -> Browse list of users
Then checked database table: mdl_users: deleted=1 on those users(users I have deleted). Active users are deleted=0.
Also reset courses.

Step3: Executed cron job:
site admin -> security ->site policies 
Example: http://site.example.com/admin/cron.php?password=opensesame
Executed our own site cron job.

Step4:
Then checked on database table: mdl_files and checked on moodleData folder
Files are still there. 


Do you have any idea why files are not becoming 'orphan'?
What should I do to make file orphan or to delete files from moodleData?


 
Average of ratings: -
Picture of Leon Stringer
Re: How Moodle's garbage collection works?
Particularly helpful Moodlers

In step 3 when you reset the courses, did you select Delete all submissions under Assignments?

 
Average of ratings: -
Picture of Mohammad khondakar
Re: How Moodle's garbage collection works?
 

Yes,  checked all fields and  Delete all submissions under Assignments/quiz/forum from all the courses.

Still files are exist in moodleData folder and related info in database (mdl_files).

What I guess is , even though I runned cron job several times, the scheduled task for deleting 'orphane file' is not running.  

Anybody knows about that schedule task? What is the name of that scheduled task or how to run?

Thank you very much.

 
Average of ratings: -
Picture of Helen Foster
Re: How Moodle's garbage collection works?
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTestersTranslators

Hello,

If you delete a user, the account will not actually be deleted. Please see the section on deleting an account in the documentation Browse list of users for more information.

 
Average of ratings: -