跳到主要内容
跳到主要内容

Compaction Action

Compaction Action

该 API 用于查看某个 BE 节点总体的 compaction 状态,或者指定 tablet 的 compaction 状态。也可以用于手动触发 Compaction。

查看 Compaction 状态

节点整体 compaction 状态

curl -X GET http://be_host:webserver_port/api/compaction/run_status

返回 JSON 格式

{
"CumulativeCompaction": {
"/home/disk1" : [10001, 10002],
"/home/disk2" : [10003]
},
"BaseCompaction": {
"/home/disk1" : [10001, 10002],
"/home/disk2" : [10003]
}
}

该结构表示某个数据目录下,正在执行 compaction 任务的 tablet 的 id,以及 compaction 的类型。

指定 tablet 的 compaction 状态

curl -X GET http://be_host:webserver_port/api/compaction/show?tablet_id=xxxx

若 tablet 不存在,返回 JSON 格式的错误:

{
"status": "Fail",
"msg": "Tablet not found"
}

若 tablet 存在,则返回 JSON 格式的结果:

{
"cumulative policy type": "SIZE_BASED",
"cumulative point": 50,
"last cumulative failure time": "2019-12-16 18:13:43.224",
"last base failure time": "2019-12-16 18:13:23.320",
"last cumu success time": ,
"last base success time": "2019-12-16 18:11:50.780",
"rowsets": [
"[0-48] 10 DATA OVERLAPPING 574.00 MB",
"[49-49] 2 DATA OVERLAPPING 574.00 B",
"[50-50] 0 DELETE NONOVERLAPPING 574.00 B",
"[51-51] 5 DATA OVERLAPPING 574.00 B"
],
"missing_rowsets": [],
"stale version path": [
{
"path id": "2",
"last create time": "2019-12-16 18:11:15.110 +0800",
"path list": "2-> [0-24] -> [25-48]"
},
{
"path id": "1",
"last create time": "2019-12-16 18:13:15.110 +0800",
"path list": "1-> [25-40] -> [40-48]"
}
]
}

结果说明:

  • cumulative policy type:当前tablet所使用的 cumulative compaction 策略。
  • cumulative point:base 和 cumulative compaction 的版本分界线。在 point(不含)之前的版本由 base compaction 处理。point(含)之后的版本由 cumulative compaction 处理。
  • last cumulative failure time:上一次尝试 cumulative compaction 失败的时间。默认 10min 后才会再次尝试对该 tablet 做 cumulative compaction。
  • last base failure time:上一次尝试 base compaction 失败的时间。默认 10min 后才会再次尝试对该 tablet 做 base compaction。
  • rowsets:该 tablet 当前的 rowset 集合。如 [0-48] 表示 0-48 版本。第二位数字表示该版本中 segment 的数量。DELETE 表示 delete 版本。DATA 表示数据版本。OVERLAPPINGNONOVERLAPPING 表示segment数据是否重叠。
  • missing_rowsets: 缺失的版本。
  • stale version path:该 table 当前被合并rowset集合的合并版本路径,该结构是一个数组结构,每个元素表示一个合并路径。每个元素中包含了三个属性:path id 表示版本路径id,last create time 表示当前路径上最近的 rowset 创建时间,默认在这个时间半个小时之后这条路径上的所有 rowset 会被过期删除。

示例

curl -X GET http://192.168.10.24:8040/api/compaction/show?tablet_id=10015

手动触发 Compaction

curl -X POST http://be_host:webserver_port/api/compaction/run?tablet_id=xxxx\&compact_type=cumulative

当前仅能执行一个手动compaction任务,其中compact_type取值为base或cumulative

若 tablet 不存在,返回 JSON 格式的错误:

{
"status": "Fail",
"msg": "Tablet not found"
}

若 compaction 执行任务触发失败时,返回 JSON 格式的错误:

{
"status": "Fail",
"msg": "fail to execute compaction, error = -2000"
}

若 compaction 执行触发成功时,则返回 JSON 格式的结果:

{
"status": "Success",
"msg": "compaction task is successfully triggered."
}

结果说明:

  • status:触发任务状态,当成功触发时为Success;当因某些原因(比如,没有获取到合适的版本)时,返回Fail。
  • msg:给出具体的成功或失败的信息。

示例

curl -X POST http://192.168.10.24:8040/api/compaction/run?tablet_id=10015\&compact_type=cumulative

手动 Compaction 执行状态

curl -X GET http://be_host:webserver_port/api/compaction/run_status?tablet_id=xxxx

若 tablet 不存在,返回 JSON 格式:

{
"status": "Fail",
"msg": "Tablet not found"
}

若 tablet 存在并且 tablet 不在正在执行 compaction,返回 JSON 格式:

{
"status" : "Success",
"run_status" : false,
"msg" : "this tablet_id is not running",
"tablet_id" : 11308,
"schema_hash" : 700967178,
"compact_type" : ""
}

若 tablet 存在并且 tablet 正在执行 compaction,返回 JSON 格式:

{
"status" : "Success",
"run_status" : true,
"msg" : "this tablet_id is running",
"tablet_id" : 11308,
"schema_hash" : 700967178,
"compact_type" : "cumulative"
}

结果说明:

  • run_status:获取当前手动 compaction 任务执行状态

示例

curl -X GET http://192.168.10.24:8040/api/compaction/run_status?tablet_id=10015