Skip to content

branch-3.0: [feat](recycler) Add http api for statistics recycler metrics #52523 - #53117

Merged
dataroaring merged 1 commit into
branch-3.0from
auto-pick-52523-branch-3.0
Jul 12, 2025
Merged

branch-3.0: [feat](recycler) Add http api for statistics recycler metrics #52523#53117
dataroaring merged 1 commit into
branch-3.0from
auto-pick-52523-branch-3.0

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Cherry-picked from #52523

### Release note
call this api to directly know how many resources need to be recycled at
this time (number and size (bytes)) in brpc metrics, even if
config::enable_recycler_metrics is false
```
// metrics
recycler_instance_to_recycle_num
recycler_instance_to_recycle_bytes
```
usage:
```
// brpc_listen_port is port of recycler
// If instance id is empty, no action will be performed.
// if instance id is "*", it will statistics all instances
curl "127.0.0.1:${brpc_listen_port}/RecyclerService/http/statistics_recycle?token=greedisgood9999" \
-d '{
"instance_ids" : ["*"],
"resource_type" : ["recycle_indexes"]
}'
// if "resource_type" is empty or it is "*", it will statistics all resource types in all instances
curl "127.0.0.1:${brpc_listen_port}/RecyclerService/http/statistics_recycle?token=xxxx" \
-d '{
"instance_ids" : ["default_instance_id", "default_instance_id_0", ...]
}'
curl "127.0.0.1:${brpc_listen_port}/RecyclerService/http/statistics_recycle?token=greedisgood9999" \
-d '{
"instance_ids" : ["*"]
}'
// else it is not empty, it will only stastics specified resource type
// such as rowset, index, partition
curl "127.0.0.1:${brpc_listen_port}/RecyclerService/http/statistics_recycle?token=xxxx" \
-d '{
"instance_ids" : ["default_instance_id", "default_instance_id_0", ...],
"resource_type" : ["recycle_rowsets", "recycle_indexes", "recycle_partitions", ...]
}'
// invalid arg
curl "127.0.0.1:5271/RecyclerService/http/statistics_recycle?token=xxx" \
-d '{
"instance_ids" : ["default_instance_id"],
"resource_type" : ["11"]
}'
invalid resource type: invalid_resource_type, valid resource_type have [recycle_indexes, recycle_partitions, recycle_tmp_rowsets, recycle_rowsets, abort_timeout_txn, recycle_expired_txn_label, recycle_versions, recycle_copy_jobs, recycle_stage, recycle_expired_stage_objects, recycle_tablet, recycle_segment]
curl "127.0.0.1:5271/RecyclerService/http/statistics_recycle?token=xxx" \
-d '{
"instance_ids" : ["invalid_instance_id"]
}'
invalid instance id: invalid_instance_id
```
eg.
```
curl "127.0.0.1:5271/RecyclerService/http/statistics_recycle?token=greedisgood9999" \
-d '{
"instance_ids" : ["*"],
"resource_type" : ["*"]
}'
Instance ID: default_instance_id
----------------------------------------
Task Type: abort_timeout_txn
• Need to abort timeout txn count: 0 items
• Need to recycle timeout txn size: 0 bytes
----------------------------------------
Task Type: recycle_copy_jobs
• Need to recycle copy job count: 0 items
• Need to recycle copy job size: 0 bytes
----------------------------------------
Task Type: recycle_expired_stage_objects
• Need to recycle expired stage object count: 0 items
• Need to recycle expired stage object size: 0 bytes
----------------------------------------
Task Type: recycle_expired_txn_label
• Need to recycle expired txn label count: 24 items
• Need to recycle expired txn label size: 0 bytes
----------------------------------------
Task Type: recycle_indexes
• Need to recycle index count: 4 items
• Need to recycle index size: 16195 bytes
----------------------------------------
Task Type: recycle_partitions
• Need to recycle partition count: 0 items
• Need to recycle partition size: 0 bytes
----------------------------------------
Task Type: recycle_rowsets
• Need to recycle rowset count: 9 items
• Need to recycle rowset size: 7573 bytes
----------------------------------------
Task Type: recycle_segment
• Need to recycle segment count: 48 items
• Need to recycle segment size: 55604 bytes
----------------------------------------
Task Type: recycle_stage
• Need to recycle stage count: 0 items
• Need to recycle stage size: 0 bytes
----------------------------------------
Task Type: recycle_tablet
• Need to recycle tablet count: 30 items
• Need to recycle tablet size: 16195 bytes
----------------------------------------
Task Type: recycle_tmp_rowsets
• Need to recycle tmp rowset count: 0 items
• Need to recycle tmp rowset size: 0 bytes
----------------------------------------
Task Type: recycle_versions
• Need to recycle version count: 0 items
• Need to recycle version size: 0 bytes
----------------------------------------
```
```
curl "127.0.0.1:5271/RecyclerService/http/statistics_recycle?token=greedisgood9999" \
-d '{
"instance_ids" : ["*"],
"resource_type" : ["recycle_indexes","recycle_tablet","recycle_segment","recycle_rowsets"]
}'
Instance ID: default_instance_id
----------------------------------------
Task Type: recycle_indexes
• Need to recycle index count: 4 items
• Need to recycle index size: 16195 bytes
----------------------------------------
Task Type: recycle_rowsets
• Need to recycle rowset count: 9 items
• Need to recycle rowset size: 7573 bytes
----------------------------------------
Task Type: recycle_segment
• Need to recycle segment count: 48 items
• Need to recycle segment size: 55604 bytes
----------------------------------------
Task Type: recycle_tablet
• Need to recycle tablet count: 30 items
• Need to recycle tablet size: 16195 bytes
----------------------------------------
```
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hello-stephen

Copy link
Copy Markdown
Contributor

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 16.87% (168/996) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage80.80% (1145/1417)
Line Coverage64.52% (19432/30117)
Region Coverage66.23% (9869/14902)
Branch Coverage55.71% (5175/9290)

@doris-robot

Copy link
Copy Markdown

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage41.21% (10949/26572)
Line Coverage31.95% (93806/293610)
Region Coverage31.09% (48360/155550)
Branch Coverage27.53% (24774/89978)

@dataroaringdataroaring left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions

Copy link
Copy Markdown
ContributorAuthor

PR approved by at least one committer and no changes requested.

@github-actionsgithub-actionsBot added approved Indicates a PR has been approved by one committer. reviewed labels Jul 12, 2025
@github-actions

Copy link
Copy Markdown
ContributorAuthor

PR approved by anyone and no changes requested.

@dataroaring
dataroaring merged commit a7c827d into branch-3.0Jul 12, 2025
@github-actions
github-actionsBot deleted the auto-pick-52523-branch-3.0 branch July 12, 2025 02:17
@gavinchougavinchou mentioned this pull request Aug 15, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@hello-stephen@doris-robot@dataroaring@wyxxxcat