Categories:

Information Schema , Table functions

REPLICATION_GROUP_REFRESH_PROGRESS、REPLICATION_GROUP_REFRESH_PROGRESS_BY_JOB、REPLICATION_GROUP_REFRESH_PROGRESS_ALL

您可以使用 REPLICATION_GROUP_REFRESH_PROGRESS 系列表函数来查询复制或故障转移组的刷新操作状态:

  • REPLICATION_GROUP_REFRESH_PROGRESS returns a JSON object indicating the refresh status for a secondary replication or failover group by name.
  • REPLICATION_GROUP_REFRESH_PROGRESS_BY_JOB returns a JSON object indicating the refresh status for a secondary replication or failover group by query ID.
  • REPLICATION_GROUP_REFRESH_PROGRESS_ALL returns a JSON object indicating the refresh status for all the secondary replication and failover groups.

Note

  • REPLICATION_GROUP_REFRESH_PROGRESS only returns the replication or failover group refresh activity for the most recent refresh if it occurred within the last 14 days.
  • REPLICATION_GROUP_REFRESH_PROGRESS_BY_JOB and REPLICATION_GROUP_REFRESH_PROGRESS_ALL return replication or failover group refresh activity within the last 14 days. By default (when no date-range arguments are provided), REPLICATION_GROUP_REFRESH_PROGRESS_ALL returns data for the last 12 hours. Use the optional DATE_RANGE_START and DATE_RANGE_END arguments to query a custom range within the 14-day retention window.

语法

REPLICATION_GROUP_REFRESH_PROGRESS( '<secondary_group_name>' )

REPLICATION_GROUP_REFRESH_PROGRESS_BY_JOB( '<query_id>' )

REPLICATION_GROUP_REFRESH_PROGRESS_ALL(
      [ DATE_RANGE_START => <constant_expr> ]
      [ , DATE_RANGE_END => <constant_expr> ] )

实参

'secondary_group_name'

辅助复制或故障转移组的名称。请注意,整个名称必须放在单引号内。

'query_id'

ID of the replication group refresh query. The query ID can be obtained from the History History tab page in the web interface.

以下实参对于 REPLICATION_GROUP_REFRESH_PROGRESS_ALL 是可选的。

DATE_RANGE_START => constant_expr ,
DATE_RANGE_END => constant_expr

返回复制刷新进度的日期/时间范围。

  • 如果既未指定开始日期,也未指定结束日期,则默认值为过去 12 小时。
  • If a start date is specified but no end date, CURRENT_DATE at midnight is used as the end of the range.
  • If an end date is specified but no start date, the range starts 12 hours prior to the start of DATE_RANGE_END.

数据保留 14 天。如果请求的范围超出了 14 天的保留期,则该函数将返回错误。

输出

该函数返回以下各列。REPLICATION_GROUP_REFRESH_PROGRESS_ALL 还有其他列,分别为结果集的前两列。

Column NameData TypeDescription
GROUP_NAMETEXT

指定哪个二级复制或故障转移组对应于结果集中的此行。仅适用于 REPLICATION_GROUP_REFRESH_PROGRESS_ALL。

GROUP_TYPETEXT

Specifies whether the group corresponding to this row in the result set is a failover group or a replication group. The value is either FAILOVER or REPLICATION. Only applies to REPLICATION_GROUP_REFRESH_PROGRESS_ALL.

PHASE_NAMETEXTName of the replication phases completed (or in progress) so far. For the list of phases, see the usage notes.
START_TIMETIMESTAMP_LTZTime when the replication phase began.
END_TIMETIMESTAMP_LTZ

Time when the phase finished, if applicable. NULL if the phase is in progress or is the terminating phase (COMPLETED/FAILED/CANCELED).

PROGRESSTEXT
  • PRIMARY_UPLOADING_DATA: Percentage of total bytes replicated.
  • SECONDARY_DOWNLOADING_METADATA: Percentage of the total number of objects replicated.
  • SECONDARY_DOWNLOADING_DATA: Percentage of total bytes replicated.

剩余阶段为空

DETAILSVARIANT
  • For phase PRIMARY_UPLOADING_METADATA:

    • primarySnapshotTimestamp: Time when the primary snapshot was created. Format is epoch time.
  • For phase PRIMARY_UPLOADING_DATA:

    • totalBytesToReplicate: Total number of bytes expected to be uploaded.
    • totalBytesToUpload: Total number of bytes to required to be uploaded.
    • bytesUploaded: Total number of bytes uploaded so far.
    • databases: List of JSON objects containing the following fields for each member database:
      • name: Database name.
      • totalBytesToReplicate: Total bytes expected to be uploaded for the database.
  • For phase SECONDARY_DOWNLOADING_DATA:

    • totalBytesToReplicate: Total number of bytes expected to be downloaded.
    • totalBytesToDownload: Actual number of bytes required to be downloaded.
    • bytesDownloaded: Actual number of bytes downloaded so far.
    • databases: List of JSON objects containing the following fields for each member database:
      • name: Database name.
      • totalBytesToReplicate: Total bytes expected to be downloaded for the database.
  • For phase SECONDARY_DOWNLOADING_METADATA:

    • totalObjects: Total number of objects to download.
    • completedObjects: Total number of objects downloaded so far.
    • objectTypes: List of JSON objects containing the following fields for each object type:
      • objectType: Type of object (for example, users, roles, grants, warehouses, schemas, tables, columns, etc).
      • totalObjects: Total number of objects of this type.
      • completedObjects: Number of completed objects of this type.
  • For phase FAILED:

    • errorCode: Error code of the failure.
    • errorMessage: Error message of the failure.

使用说明

  • When no DATE_RANGE_START or DATE_RANGE_END arguments are provided, REPLICATION_GROUP_REFRESH_PROGRESS_ALL returns data for the last 12 hours. To retrieve data beyond the last 12 hours, specify the date range explicitly. Data is available for up to 14 days.
  • 仅返回对复制组或故障转移组具有任何权限的角色的行。
  • 仅返回当前账户中辅助复制或故障转移组的行。
  • When calling an Information Schema table function, the session must have an INFORMATION_SCHEMA schema in use or the function name must be fully-qualified. For more details, see Snowflake Information Schema.
  • 以下是所处理订单中的阶段列表:

    #Phase nameDescription
    1SECONDARY_SYNCHRONIZING_MEMBERSHIPThe secondary replication or failover group receives information from the primary group about the objects included in the group, and updates its membership metadata.
    2SECONDARY_UPLOADING_INVENTORYThe secondary replication or failover group sends an inventory of its objects in the target account to the primary group.
    3PRIMARY_UPLOADING_METADATAThe primary replication or failover group creates a snapshot of metadata in the source account and sends it to the secondary group.
    4PRIMARY_UPLOADING_DATAThe primary replication or failover group copies the files the secondary group needs to reconcile any deltas between the objects in the source and target accounts.
    5SECONDARY_DOWNLOADING_METADATAThe secondary replication or failover group applies the snapshot of the metadata that was sent by the primary. The metadata updates are not applied atomically and instead applied over time.
    6SECONDARY_DOWNLOADING_DATAThe secondary replication or failover group copies the files sent by the primary group to the target account.
    7COMPLETED / FAILED / CANCELEDRefresh operation status.
  • In the PRIMARY_UPLOADING_DATA and SECONDARY_DOWNLOADING_DATA phases, the totalBytesToReplicate value is estimated prior to the replication operation. This value may differ from the totalBytesToUpload or totalBytesToDownload value in the respective phase.

    For example, if during the PRIMARY_UPLOADING_DATA phase, a previous replication operation uploaded some bytes but was canceled before the operation completed, those bytes would not be uploaded again. In that case, totalBytesToUpload would be lower than totalBytesToReplicate.

示例

To retrieve the current refresh progress for replication group rg1, execute the following statement:

SELECT phase_name, start_time, end_time, progress, details
  FROM TABLE(INFORMATION_SCHEMA.REPLICATION_GROUP_REFRESH_PROGRESS('rg1'));

要通过查询 ID 检索复制组刷新进度,请替换示例中的查询 ID 并执行以下语句:

SELECT phase_name, start_time, end_time, progress, details
  FROM TABLE(
    INFORMATION_SCHEMA.REPLICATION_GROUP_REFRESH_PROGRESS_BY_JOB(
      '012a3b45-1234-a12b-0000-1aa200012345'));

要检索所有故障转移组和复制组过去 12 小时(默认)的刷新进度,请执行以下语句:

SELECT phase_name, start_time, end_time, progress, details
  FROM TABLE(INFORMATION_SCHEMA.REPLICATION_GROUP_REFRESH_PROGRESS_ALL());

要检索所有组过去 7 天的刷新进度,请执行以下操作:

SELECT phase_name, start_time, end_time, progress, details
  FROM TABLE(
    INFORMATION_SCHEMA.REPLICATION_GROUP_REFRESH_PROGRESS_ALL(
        DATE_RANGE_START => DATEADD(D, -7, CURRENT_DATE),
        DATE_RANGE_END => CURRENT_DATE));