Compaction Action

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

查看 Compaction 状态

节点整体 compaction 状态

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

返回 JSON 格式

  1. {
  2. "CumulativeCompaction": {
  3. "/home/disk1" : [10001, 10002],
  4. "/home/disk2" : [10003]
  5. },
  6. "BaseCompaction": {
  7. "/home/disk1" : [10001, 10002],
  8. "/home/disk2" : [10003]
  9. }
  10. }

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

指定 tablet 的 compaction 状态

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

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

  1. {
  2. "status": "Fail",
  3. "msg": "Tablet not found"
  4. }

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

  1. {
  2. "cumulative policy type": "NUM_BASED",
  3. "cumulative point": 50,
  4. "last cumulative failure time": "2019-12-16 18:13:43.224",
  5. "last base failure time": "2019-12-16 18:13:23.320",
  6. "last cumu success time": ,
  7. "last base success time": "2019-12-16 18:11:50.780",
  8. "rowsets": [
  9. "[0-48] 10 DATA OVERLAPPING 574.00 MB",
  10. "[49-49] 2 DATA OVERLAPPING 574.00 B",
  11. "[50-50] 0 DELETE NONOVERLAPPING 574.00 B",
  12. "[51-51] 5 DATA OVERLAPPING 574.00 B"
  13. ],
  14. "missing_rowsets": [],
  15. "stale version path": [
  16. {
  17. "path id": "2",
  18. "last create time": "2019-12-16 18:11:15.110 +0800",
  19. "path list": "2-> [0-24] -> [25-48]"
  20. },
  21. {
  22. "path id": "1",
  23. "last create time": "2019-12-16 18:13:15.110 +0800",
  24. "path list": "1-> [25-40] -> [40-48]"
  25. }
  26. ]
  27. }

结果说明:

  • 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 会被过期删除。

示例

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

手动触发 Compaction

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

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

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

  1. {
  2. "status": "Fail",
  3. "msg": "Tablet not found"
  4. }

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

  1. {
  2. "status": "Fail",
  3. "msg": "fail to execute compaction, error = -2000"
  4. }

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

  1. {
  2. "status": "Success",
  3. "msg": "compaction task is successfully triggered."
  4. }

结果说明:

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

示例

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

手动 Compaction 执行状态

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

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

  1. {
  2. "status": "Fail",
  3. "msg": "Tablet not found"
  4. }

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

  1. {
  2. "status" : "Success",
  3. "run_status" : false,
  4. "msg" : "this tablet_id is not running",
  5. "tablet_id" : 11308,
  6. "schema_hash" : 700967178,
  7. "compact_type" : ""
  8. }

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

  1. {
  2. "status" : "Success",
  3. "run_status" : true,
  4. "msg" : "this tablet_id is running",
  5. "tablet_id" : 11308,
  6. "schema_hash" : 700967178,
  7. "compact_type" : "cumulative"
  8. }

结果说明:

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

示例

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