Skip to content

Conversation

@github-actions
Copy link
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
----------------------------------------
```
@github-actions github-actions bot requested a review from dataroaring as a code owner July 11, 2025 08:52
@hello-stephen
Copy link
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?

@dataroaring dataroaring reopened this Jul 11, 2025
@hello-stephen
Copy link
Contributor

run buildall

@hello-stephen
Copy link
Contributor

Cloud UT Coverage Report

Increment line coverage 16.87% (168/996) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 80.80% (1145/1417)
Line Coverage 64.52% (19432/30117)
Region Coverage 66.23% (9869/14902)
Branch Coverage 55.71% (5175/9290)

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 41.21% (10949/26572)
Line Coverage 31.95% (93806/293610)
Region Coverage 31.09% (48360/155550)
Branch Coverage 27.53% (24774/89978)

Copy link
Contributor

@dataroaring dataroaring left a comment

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
Contributor Author

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

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Jul 12, 2025
@github-actions
Copy link
Contributor Author

PR approved by anyone and no changes requested.

@dataroaring dataroaring merged commit a7c827d into branch-3.0 Jul 12, 2025
21 of 25 checks passed
@github-actions github-actions bot deleted the auto-pick-52523-branch-3.0 branch July 12, 2025 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants