Copy course - stuck in progress

Copy course - stuck in progress

by Todd W. Roat -
Number of replies: 6

As per title, 2 days later it just shows stuck in progress.  Any logs or places I can check?

Average of ratings: -
In reply to Todd W. Roat

Re: Copy course - stuck in progress

by Ken Task -
Picture of Particularly helpful Moodlers

Unfortunately, 'in progress' puts the copy in a background process and no button to 'cancel' now.

Places to check ... things to try?

moodledata/temp/backup/ ... think the copy course creates a backup first.

Do you see any contenthash named (bunch of letters/numbers) directories there?   If, from whatever you have to browse files (command line would be 'best') see if there is/are any .xml files - maybe moodle_backup.xml there.

xml files are asciii text so one could open in an edtor to inspect for clues.

Size of the course being copied?   Got a backup of it?   How large is that backup file?

When ever newer versions of Moodle can't finish a job it might que the job up for execution/try again at a later time.   So, hopefully, you have command line access and don't suffer from 'command line avoidance syndrome' ... in code/admin/tool/task/cli/ there is a command line only script called adhoc_task.php that's supposed to pick up where something like copy didn't finish.

cd code/admin/tool/task/cli/

php adhoc_task.php [ENTER] will bring up a help screen:

[root@sos cli]# php adhoc_task.php
Ad hoc cron tasks.

Options:
 -h, --help                Print out this help
     --showsql             Show sql queries before they are executed
     --showdebugging       Show developer level debugging information
 -e, --execute             Run all queued adhoc tasks
 -k, --keep-alive=N        Keep this script alive for N seconds and poll for new adhoc tasks
 -i  --ignorelimits        Ignore task_adhoc_concurrency_limit and task_adhoc_max_runtime limits

Example:
$sudo -u www-data /usr/bin/php admin/tool/task/cli/adhoc_task.php --execute

Also, check web server error logs.

Got any site protects - a web application firewall - that might have triggered?

Some sites are set up to write php error logs in directories where error ocurred - typically those are called 'error_log'.   Got any of those in any directory of your site?

Sorry ... no magic bullet here! Just lots of 'sluething'! :\

Might help to know some technical details about site:

Minimally .. how about Moodle version?  How hosted? (shared/dedicated/whatever)   Any issues with additional plugins?   Space issues?

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Copy course - stuck in progress

by Ken Task -
Picture of Particularly helpful Moodlers

Follow up ... there is a tracker entry that deals with the copy course interface:

https://tracker.moodle.org/browse/MDL-64843?attachmentViewMode=list

In the 'Testing Instructions' mentioned many times is the running of cron job.  While not exactly the same as your issue, is closely related.   And while not exactly mentioning the actual API/process does hint at using core backup and restore.

Does any of info in that tracker item stand out to you?

'SoS', Ken


In reply to Ken Task

Re: Copy course - stuck in progress

by Ken Task -
Picture of Particularly helpful Moodlers

And another follow up ... on a sandbox 3.9.highest copy course of 65.6 MB in size

stepped through the single screen for making a course copy of above.
Performed.   Screen refreshes and informs 'in progress'
Nothing in moodledata/temp/backup/ yet.

Ran cron job from command line

The course copy was in adhoc_task ... cron output for this test below:

Execute adhoc task: core\task\asynchronous_copy_task
... started 18:00:41. Current memory use 49.3MB.
Course copy: Processing asynchronous course copy for course id: 6
Course copy: Backing up course, id: 6
Course copy: Restoring into course, id: 9
Course copy: Copy completed in: 3 seconds
... used 4005 dbqueries
... used 2.8616149425507 seconds
Adhoc task complete: core\task\asynchronous_copy_task
Execute adhoc task: core\task\refresh_mod_calendar_events_task
... started 18:00:44. Current memory use 53.3MB.
Refreshing events for assign
Refreshing events for assignment
Refreshing events for book
Refreshing events for chat
Refreshing events for choice
Refreshing events for data
Refreshing events for feedback
Refreshing events for folder
Refreshing events for forum
Refreshing events for glossary
Refreshing events for h5pactivity
Refreshing events for imscp
Refreshing events for label
Refreshing events for lesson
Refreshing events for lti
Refreshing events for offlinequiz
Refreshing events for page
Refreshing events for quiz
Refreshing events for resource
Refreshing events for scorm
Refreshing events for survey
Refreshing events for url
Refreshing events for wiki
Refreshing events for workshop
... used 109 dbqueries
... used 0.10778307914734 seconds
Adhoc task complete: core\task\refresh_mod_calendar_events_task
Ran 2 adhoc tasks found at Tue, 29 Dec 2020 18:00:39 -0600
Cron script completed correctly
Cron completed at 18:00:44. Memory used 56.4MB.
Execution took 4.476938 seconds

Course copies in progress screen refreshed to display:
current operation complete with a status of a 'check'.

So bottom line for your issue might be the running of cron.   Check the cron job set up.   You can also run the cron job via the web interface ... although without knowing the size of the course to be copied that might time out.

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Copy course - stuck in progress

by Todd W. Roat -
That was bad form, not much details of info. I should know better.
This is Moodle 3.9.1 (build 20200713) hosted with TMD, access thru cPanel interface.

moodledata/temp/backup/ ...
Yes, there ares 4 in there over the period of time I have been trying to copy this course, so it may be backing up entrire site first? They are all the same [LARGE] 2.5GB so must have finished.  Last backup I have of the course (MBZ file is only 54MB) I seem to have "Softalicious" running these BKs because in Moodle proper I dont see any since August.

soft bks

Do you see any contenthash named (bunch of letters/numbers) directories there? 
Yes, there are some in there.  The few logs with info in them all contain the same info as below.  No XML files found.

moddle directory

Size of the course being copied?   Got a backup of it?   How large is that backup file?

MBX is 54 MB:
mbz

cd code/admin/tool/task/cli/
I do actually suffer "command line avoidance syndrome".  But I went in anyway.  I kept getting an unknown  -u command error.  I was in terminal via cPanel

terminal

No recent error logs fcound.  And no site protects on that I know of.

Thanks  for any sleuthing help.

It seems like its copying the entire 2.5 GB site, while the course I think is only 54MB.
Attachment moodledata bk log.jpg
In reply to Todd W. Roat

Re: Copy course - stuck in progress

by Ken Task -
Picture of Particularly helpful Moodlers

Softac ... ugh!

Those look like site backups?  The .tar.gz filename extensions.
Moodle backups have .mbz extensions.

Contenthash question ...
any .log file in moodledata/temp/backup/ that is 0 bytes in size can be
ignored in this case ... indicates a successful backup of a course.
any .log file over 0 bytes indicates there could have been an issue.

What I was trying to get you to do is look in a directory ...
screen shot shows 3ff7blahblah directory.
Still there today?   Hope not.
Change into: cd 3ff7[tab key on keyboard]
pwd to make sure you are in that directory
ls -l to see what's in it.

Running of commands.
Screen shot shows user is vm1277. One has to adjust -u (user) provided in the help screen for the command **example** cause www-data - the typical user under which web service would run on a standalone ubuntu/debian server - probably doesn't exist on *your* system.

So

if you have already changed directories (cd command) to the directory where the script resides you did this:

cd public_html/admin/tool/task/cli/

pwd [ENTER]

will show present working directory:

ls -l will show the files at that location.

and should show owner of files as well as permissions.

You should see 2 php scripts:

adhoc_task.php and schedule_task.php

To execute:

php adhoc_task.php -e [ENTER]

OR if above php isn't php-cli/

/usr/bin/php adhoc_task.php -e [ENTER]

Be prepared to wait ... script might take some time to run.

Be patient! smile

'SoS', Ken

In reply to Ken Task

Re: Copy course - stuck in progress

by Todd W. Roat -
Sorry for the late rely, esp when your support responses are fast. This running of php adhoc_task.php -e from terminal seems to have worked. What seems odd to me is that it seems to fix the issue way before finishing. Almost literally by hitting Enter.

I tested that by copying anohter course. In one window I had the web interface copying course screen showing "Copy pending" that gets stuck. In a separate window I have the terminal window open. Once I run php adhoc_task.php -e and script starts, within 10 seconds the GUI window releases the pending and processes the job. Kind of way before it seems much script processing is even close to done.

Regardless, the solution worked. Thank you! But it seems a clunky solution everytime I want to copy a course its going to hang until I run that command via terminal. Assume something else must not be set right that prevents for GUI copy from working?
Average of ratings: Useful (1)