MDL-49399 task: Add task log table
This commit is contained in:
@@ -1588,6 +1588,9 @@ $string['privacy:metadata:task_adhoc'] = 'The status of adhoc tasks.';
|
||||
$string['privacy:metadata:task_adhoc:component'] = 'The component owning the task.';
|
||||
$string['privacy:metadata:task_adhoc:nextruntime'] = 'The earliest time to run this task.';
|
||||
$string['privacy:metadata:task_adhoc:userid'] = 'The user to run the task as.';
|
||||
$string['privacy:metadata:task_log'] = 'Log output for a log';
|
||||
$string['privacy:metadata:task_log:component'] = 'The component owning the task.';
|
||||
$string['privacy:metadata:task_log:userid'] = 'The user that the task belonged to.';
|
||||
$string['privacy:metadata:upgrade_log'] = 'The upgrade log.';
|
||||
$string['privacy:metadata:upgrade_log:backtrace'] = 'Any backtrace associated with this upgrade step.';
|
||||
$string['privacy:metadata:upgrade_log:details'] = 'Extra information relating to the upgrade.';
|
||||
|
||||
@@ -88,6 +88,13 @@ class provider implements
|
||||
'userid' => 'privacy:metadata:task_adhoc:userid',
|
||||
], 'privacy:metadata:task_adhoc');
|
||||
|
||||
// The task_log table stores debugging data for tasks.
|
||||
// These are cleaned regularly and intended purely for debugging.
|
||||
$collection->add_database_table('task_log', [
|
||||
'component' => 'privacy:metadata:task_log:component',
|
||||
'userid' => 'privacy:metadata:task_log:userid',
|
||||
], 'privacy:metadata:task_log');
|
||||
|
||||
// The events_queue includes information about pending events tasks.
|
||||
// These are stored for short periods whilst being processed into other locations.
|
||||
$collection->add_database_table('events_queue', [
|
||||
|
||||
+22
-1
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20181105" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20181205" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -3305,6 +3305,27 @@
|
||||
<INDEX NAME="nextruntime_idx" UNIQUE="false" FIELDS="nextruntime"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="task_log" COMMENT="The log table for all tasks">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="type" TYPE="int" LENGTH="4" NOTNULL="true" SEQUENCE="false" COMMENT="The type of task. Scheduled task = 0; Adhoc task = 1."/>
|
||||
<FIELD NAME="component" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The component that the task belongs to"/>
|
||||
<FIELD NAME="classname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The class of the task being run"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The userid that the task was configured to run as (Adhoc tasks only)"/>
|
||||
<FIELD NAME="timestart" TYPE="number" LENGTH="20" NOTNULL="true" SEQUENCE="false" DECIMALS="10" COMMENT="The start time of the task"/>
|
||||
<FIELD NAME="timeend" TYPE="number" LENGTH="20" NOTNULL="true" SEQUENCE="false" DECIMALS="10" COMMENT="The end time of the task"/>
|
||||
<FIELD NAME="dbreads" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The number of DB reads performed during the task."/>
|
||||
<FIELD NAME="dbwrites" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The number of DB writes performed during the task."/>
|
||||
<FIELD NAME="result" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false" COMMENT="Whether the task was successful or not. 0 = pass; 1 = fail."/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="classname" UNIQUE="false" FIELDS="classname"/>
|
||||
<INDEX NAME="timestart" UNIQUE="false" FIELDS="timestart"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="messageinbound_handlers" COMMENT="Inbound Message Handler definitions.">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
|
||||
@@ -2516,5 +2516,37 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2018120301.02);
|
||||
}
|
||||
|
||||
if ($oldversion < 2019011500.00) {
|
||||
// Define table task_log to be created.
|
||||
$table = new xmldb_table('task_log');
|
||||
|
||||
// Adding fields to table task_log.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('type', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('component', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('classname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timestart', XMLDB_TYPE_NUMBER, '20, 10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timeend', XMLDB_TYPE_NUMBER, '20, 10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('dbreads', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('dbwrites', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('result', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null);
|
||||
|
||||
// Adding keys to table task_log.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
|
||||
|
||||
// Adding indexes to table task_log.
|
||||
$table->add_index('classname', XMLDB_INDEX_NOTUNIQUE, ['classname']);
|
||||
$table->add_index('timestart', XMLDB_INDEX_NOTUNIQUE, ['timestart']);
|
||||
|
||||
// Conditionally launch create table for task_log.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2019011500.00);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2019011100.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2019011500.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user