by Jason Lau.
hi ken
thanks
before every restore, i clean-up prior restore entries in `mdl_task_adhoc` and `mdl_backup_controllers` (learnt hard way that it blocks restore if there's any pending)
also I remove everything in `moodledata/temp/backup`
just re-ran restore, still same ... in `moodledata/temp/backup` i see
```
/opt/moodle_deploy/moodledata/temp/backup# ls -ltr
total 8
drwxrwsrwx 6 www-data root 4096 Mar 26 10:54 e61500005ead369497bd49af28446e4b
-rw-rw-rw- 1 www-data root 3375 Mar 26 10:55 3cc5ea7b72c75643155b282a515a7a04.log
```
the log didn't show much info
```
/opt/moodle_deploy/moodledata/temp/backup# cat 3cc5ea7b72c75643155b282a515a7a04.log
[26 March 2025 at 10:54 am] [info] instantiating restore controller 3cc5ea7b72c75643155b282a515a7a04
[26 March 2025 at 10:54 am] [debug] setting controller status to 100
[26 March 2025 at 10:54 am] [debug] loading backup info
[26 March 2025 at 10:54 am] [debug] loading controller plan
[26 March 2025 at 10:54 am] [debug] setting controller status to 300
[26 March 2025 at 10:54 am] [debug] applying restore defaults
[26 March 2025 at 10:54 am] [debug] Unknown setting: questionbank
[26 March 2025 at 10:54 am] [debug] setting controller status to 400
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] setting controller status to 500
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum 3a6e854408e5a45efb5992ef527e569d
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum 3a6e854408e5a45efb5992ef527e569d
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum 3a6e854408e5a45efb5992ef527e569d
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] setting controller status to 600
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum 12e7e5fdcced98fd70a411f3f2b4971c
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [debug] setting controller status to 700
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum f62ed702c54d373b55444be7b1a5b473
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum f62ed702c54d373b55444be7b1a5b473
[26 March 2025 at 10:55 am] [debug] loading controller from db
[26 March 2025 at 10:55 am] [debug] setting controller status to 800
[26 March 2025 at 10:55 am] [debug] saving controller to db
[26 March 2025 at 10:55 am] [debug] calculating controller checksum bcaf41bb8e484f13814df13653f7dddc
[26 March 2025 at 10:55 am] [debug] loading controller from db
[26 March 2025 at 10:55 am] [debug] setting controller status to 900
[26 March 2025 at 10:55 am] [debug] saving controller to db
```
cron log show same as before (i reduce mem back to 512MB)
```
Execute adhoc task: core\task\asynchronous_restore_task
Adhoc task id: 24
Adhoc task custom data: {"backupid":"3cc5ea7b72c75643155b282a515a7a04"}
... started 10:55:02. Current memory use 44.5 MB.
Processing asynchronous restore for id: 3cc5ea7b72c75643155b282a515a7a04
loading controller from db
setting controller status to 800
saving controller to db
calculating controller checksum bcaf41bb8e484f13814df13653f7dddc
loading controller from db
setting controller status to 900
saving controller to db
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /var/www/html/moodle/backup/util/helper/backup_general_helper.class.php on line 49
```
not sure ... the backup code appears to be looping and leaking memory perhaps ?
thanks
before every restore, i clean-up prior restore entries in `mdl_task_adhoc` and `mdl_backup_controllers` (learnt hard way that it blocks restore if there's any pending)
also I remove everything in `moodledata/temp/backup`
just re-ran restore, still same ... in `moodledata/temp/backup` i see
```
/opt/moodle_deploy/moodledata/temp/backup# ls -ltr
total 8
drwxrwsrwx 6 www-data root 4096 Mar 26 10:54 e61500005ead369497bd49af28446e4b
-rw-rw-rw- 1 www-data root 3375 Mar 26 10:55 3cc5ea7b72c75643155b282a515a7a04.log
```
the log didn't show much info
```
/opt/moodle_deploy/moodledata/temp/backup# cat 3cc5ea7b72c75643155b282a515a7a04.log
[26 March 2025 at 10:54 am] [info] instantiating restore controller 3cc5ea7b72c75643155b282a515a7a04
[26 March 2025 at 10:54 am] [debug] setting controller status to 100
[26 March 2025 at 10:54 am] [debug] loading backup info
[26 March 2025 at 10:54 am] [debug] loading controller plan
[26 March 2025 at 10:54 am] [debug] setting controller status to 300
[26 March 2025 at 10:54 am] [debug] applying restore defaults
[26 March 2025 at 10:54 am] [debug] Unknown setting: questionbank
[26 March 2025 at 10:54 am] [debug] setting controller status to 400
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] setting controller status to 500
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum 3a6e854408e5a45efb5992ef527e569d
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum 3a6e854408e5a45efb5992ef527e569d
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum 3a6e854408e5a45efb5992ef527e569d
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] setting controller status to 600
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum 12e7e5fdcced98fd70a411f3f2b4971c
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [debug] setting controller status to 700
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum f62ed702c54d373b55444be7b1a5b473
[26 March 2025 at 10:54 am] [debug] loading controller from db
[26 March 2025 at 10:54 am] [info] checking plan security
[26 March 2025 at 10:54 am] [debug] saving controller to db
[26 March 2025 at 10:54 am] [debug] calculating controller checksum f62ed702c54d373b55444be7b1a5b473
[26 March 2025 at 10:55 am] [debug] loading controller from db
[26 March 2025 at 10:55 am] [debug] setting controller status to 800
[26 March 2025 at 10:55 am] [debug] saving controller to db
[26 March 2025 at 10:55 am] [debug] calculating controller checksum bcaf41bb8e484f13814df13653f7dddc
[26 March 2025 at 10:55 am] [debug] loading controller from db
[26 March 2025 at 10:55 am] [debug] setting controller status to 900
[26 March 2025 at 10:55 am] [debug] saving controller to db
```
cron log show same as before (i reduce mem back to 512MB)
```
Execute adhoc task: core\task\asynchronous_restore_task
Adhoc task id: 24
Adhoc task custom data: {"backupid":"3cc5ea7b72c75643155b282a515a7a04"}
... started 10:55:02. Current memory use 44.5 MB.
Processing asynchronous restore for id: 3cc5ea7b72c75643155b282a515a7a04
loading controller from db
setting controller status to 800
saving controller to db
calculating controller checksum bcaf41bb8e484f13814df13653f7dddc
loading controller from db
setting controller status to 900
saving controller to db
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /var/www/html/moodle/backup/util/helper/backup_general_helper.class.php on line 49
```
not sure ... the backup code appears to be looping and leaking memory perhaps ?