SQL, Spark, and MapReduce jobs submitted in the MaxCompute console are converted into MaxCompute instances. This topic describes common operations on instances, such as query the information and status of a specified instance, stop an instance, and obtain the job operational log of an instance.

Each MaxCompute instance has a unique ID. The instance ID is permanently valid. The following table describes common statements that are used for instance operations.
Operation Description Role Operation platform
View instance information Views instance information. Users who have the READ permission on instances or the LIST permission on the objects in a project You can execute the statements described in this topic on the following platforms:
Query instance status Queries the status of a specified instance. Users who have the READ permission on instances
View information of running instances Views the information of instances that are running in a project. Users who have the READ permission on instances or the LIST permission on the objects in a project
Stop an instance Stops a specified instance that is in the Running state. Users who have the WRITE permission on instances
Obtain job information of an instance Obtains job information based on a specified instance ID. Users who have the READ permission on instances
Obtain the operational log of jobs in an instance Obtains the operational log of jobs based on a specified instance ID.

View instance information

Views instance information. The information includes StartTime (in seconds), RunTime (in seconds), Status, InstanceID, Owner, and Query statements.

  • Syntax
    show instances [from <startdate> to <enddate>] [<number>];
    show p [from <startdate> to <enddate>] [<number>];
    show instances [-all];
    show p [-all][-limit <number>];
    show p -p <project_name>;
  • Parameters
    • startdate and enddate: optional. If you configure the two parameters, information of the instances submitted from the startdate to the enddate is returned. The values of these parameters must be in the yyyy-mm-dd format, in days. If you do not configure these parameters, information of the instances submitted in the last three days is returned.
    • number: optional. The number of instances that you want to return. If you specify this parameter, information about N instances submitted at the time nearest to the current time is returned in chronological order. N is specified by number. If you do not specify this parameter, information of the instances that meet specific requirements is returned.
    • -all: optional. All the instances executed in the current project are returned. By default, a maximum of 50 instance records can be returned.
    • -limit <number>: optional. The number of instance records that you want to return. For example, show p -all -limit 100 indicates that 100 instance records that are executed in the current project are returned.
    • project_name: required. The name of the project. Your account must be a member of the project.
  • Example
    -- View the information of all instances in the current project.
    show p;
    Returned results:
    StartTime             RunTime  Status   InstanceID                    Owner                              Query
    2015-04-28 13:57:55   1s       Success  20150428xxxxxxxxxxxxxxxxxx   ALIYUN$xxxxx@aliyun-inner.com       select * from tab_pack_priv limit 20;
    ...    ...    ...    ...    ...    ...

Query instance status

Queries the status of a specified instance. If the instance is created by a different user, an error is returned when you query the status of this instance.

  • Syntax
    status <instance_id>;
  • Parameters

    instance_id: required. The ID of an instance whose status you want to query. Each instance ID is unique.

  • Returned results
    An instance can be in one of the following states:
    • Running: The instance is running.
    • Success: Instance operation succeeded.
    • Waiting: The instance is waiting to run.
    • Failed: The job failed. The data in the destination table is not modified.
    • Cancelled: The instance is stopped.
    • Terminated: The job is completed.
  • Example
    -- Query the status of the instance with the ID of 20131225123xxxxxxxxxxxxxxx.
    status 20131225123xxxxxxxxxxxxxxx;
    Returned results:
    Success

View information of running instances

Views the information of instances that are running in a project. The information includes InstanceID, Owner, Type, StartTime, Progress, Status, Priority, RuntimeUsage (CPU/MEM), totalUsage (CPU/MEM), and QueueingInfo (POS/LEN).

  • Syntax
    -- View the information of the running instances submitted by the current account in the current project.
    top instance;
    -- Return the information of all or a specified number of running instances in the current project.
    top instance [-all][-limit <number>];
  • Parameters
    • -all: optional. All the jobs that are running in the current project are returned. By default, a maximum of 50 jobs can be returned.
    • -limit number: optional. A specified number of jobs that are running in the current project are returned.
  • Example
    -- Return the information of the first five instances that are running in the current project.
    top instance -limit 5;
    Returned results:
    QueueingInstances: 0 total.

Stop an instance

Stops a specified instance that is in the Running state.
Note The execution of this statement is an asynchronous process. After the system accepts the request and returns a result, it does not mean that the distributed job has been stopped. Instead, it only means that the system has received the request. You must execute the STATUS statement to check the status of the instance.
  • Syntax
    kill <instance_id>;
  • Parameter

    instance_id: the ID of an instance. Each instance ID is unique. Only an instance in the Running state can be specified. Otherwise, an error is returned.

  • Example
    -- Stop the instance with the ID of 20131225123xxxxxxxxxxxxxxx.
    kill 20131225123xxxxxxxxxxxxxxx;

Obtain job information of an instance

Obtains job information based on a specified instance ID. The information includes SQL, Owner, StartTime, EndTime, and Status.

  • Syntax
    desc instance <instance_id>;
  • Parameter

    instance_id: the ID of an instance. Each instance ID is unique.

  • Example
    -- Query job information of the instance with the ID of 20150715xxxxxxxxxxxxxxx.
    desc instance 20150715xxxxxxxxxxxxxxx;
    Returned results:
    ID                                      20150715xxxxxxxxxxxxxxx
    Owner                                   ALIYUN$XXXXXX@alibaba-inc.com
    StartTime                               2015-07-15 18:34:41
    EndTime                                 2015-07-15 18:34:42
    Status                                  Terminated
    console_select_query_task_1436956481295 Success
    Query                                   select * from mj_test;

Obtain the operational log of jobs in an instance

Obtains the operational log of jobs based on a specified instance ID. The log includes the URL of Logview. You can view the log details of jobs in Logview.
Note You can open only the Logview for the instances created in the last three days. For instances that are created for more than three days, you can obtain the Logview URLs from their logs.
  • Syntax
    wait <instance_id>;
  • Parameter

    instance_id: the ID of an instance. Each instance ID is unique.

  • Example
    -- Query the operational log of jobs for the instance with the ID of 20170925161122379gxxxxxx.
    wait 20170925161122379gxxxxxx;
    Returned results:
    ID = 20170925161122379g3xxxxxx
    Log view:
    http://logview.odps.aliyun.com/logview/?h=http://service.odps.aliyun.com/api&p=alian&i=201709251611223xxxxxxdqp&token=XXXXXXvbiI6IjEifQ==
    Job Queueing...
    Summary:
    resource cost: cpu 0.05 Core * Min, memory 0.05 GB * Min
    inputs:
            alian.bank_data: 41187 (588232 bytes)
    outputs:
            alian.result_table: 8 (640 bytes)
    Job run time: 2.000
    Job run mode: service job
    Job run engine: execution engine
    M1:
            instance count: 1
            run time: 1.000
            instance time:
                    min: 1.000, max: 1.000, avg: 1.000
            input records:
                    TableScan_REL5213301: 41187  (min: 41187, max: 41187, avg: 41187
    )
            output records:
                    StreamLineWrite_REL5213305: 8  (min: 8, max: 8, avg: 8)
    R2_1:
            instance count: 1
            run time: 2.000
            instance time:
                    min: 2.000, max: 2.000, avg: 2.000
            input records:
                    StreamLineRead_REL5213306: 8  (min: 8, max: 8, avg: 8)
            output records:
                    TableSink_REL5213309: 8  (min: 8, max: 8, avg: 8)