Skip to content

Reflect running tasks in system.background_schedule_pool{,_log}#92587

Merged
azat merged 3 commits intoClickHouse:masterfrom
azat:better-system.background_schedule_pool
Dec 24, 2025
Merged

Reflect running tasks in system.background_schedule_pool{,_log}#92587
azat merged 3 commits intoClickHouse:masterfrom
azat:better-system.background_schedule_pool

Conversation

@azat
Copy link
Copy Markdown
Member

@azat azat commented Dec 18, 2025

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Reflect running tasks in system.background_schedule_pool{,_log}. Add documentation.

Follow-up for: #91157

azat added 3 commits December 18, 2025 20:11
Since I've added documentaiton I was filling a shame that the
executing/elapsed_ms are useless columns.

This patch does not looks great, but it will improve introspection
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Dec 18, 2025

Workflow [PR], commit [5a2eb04]

Summary:

job_name test_name status info comment
Docs check failure
Build docusaurus failure cidb
Stateless tests (amd_binary, ParallelReplicas, s3 storage, parallel) failure
02319_lightweight_delete_on_merge_tree FAIL cidb
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting in Subquery: the query: (STID: 1941-1bfa) FAIL cidb, issue

UInt64 task_type = getFunctionID(task_info.function);
auto & group = task_groups[task_type];
group.tasks.emplace_back(task_info.shared_from_this());
auto task_ptr = task_info.shared_from_this();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting that num_running, I suppose, should be decremented here as well

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

AFAICS we inc/dec it only in BackgroundSchedulePool::threadFunction, so when we really execute callback, so I think it is OK

But the behavior of running_tasks is slightly different, we erase the task from this container inside BackgroundSchedulePool::threadFunction only if !scheduled and if it is scheduled here, the reason we do so is to preserve the task at least in one container to make it always available for introspection if it was rescheduled inside the callback.

@azat azat enabled auto-merge December 24, 2025 11:06
@azat azat added this pull request to the merge queue Dec 24, 2025
Merged via the queue into ClickHouse:master with commit 5327bfe Dec 24, 2025
127 of 131 checks passed
@azat azat deleted the better-system.background_schedule_pool branch December 24, 2025 11:22
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants