Skip to content

Revert "Fix a hang in the parallel Parquet encoder when it cannot start an extra thread" - #113155

Merged
alexey-milovidov merged 1 commit into
masterfrom
revert-112959-fix/parquet-parallel-encoder-cancel-hang
Aug 3, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
revert-112959-fix/parquet-parallel-encoder-cancel-hang

Conversation

@nikitamikhaylov

@nikitamikhaylov nikitamikhaylov commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Reverts #112959

Broke private CI.

Version info

  • Merged into: 26.8.1.702 (included in 26.8 and later)

@clickhouse-gh

clickhouse-gh Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f41c98e]


AI Review

Summary

This PR reverts #112959 because the earlier change reportedly broke private CI. I do not think the revert is safe to merge: removing the threads_running increment puts the parallel Parquet encoder back into the state where a failed extra trySchedule can strand queued work with no counted worker, so finalizeImpl can wait indefinitely. The same revert also deletes the focused regression test for that starvation path.

Findings

❌ Blockers

  • [src/Processors/Formats/Impl/ParquetBlockOutputFormat.cpp:386] Removing the ++threads_running; after a successful trySchedule reintroduces the live-thread undercount that #112959 fixed. Every worker scheduled through trySchedule still decrements threads_running on exit in threadFunction, so the counter can hit 0 or wrap while encoder tasks remain queued. From that state startMoreThreadsIfNeeded can no longer rely on the scheduleOrThrowOnError branch to guarantee a worker, and a later trySchedule failure can leave a non-empty task_queue with no thread to drain it, hanging finalizeImpl. Suggested fix: keep the counter increment and, if the private CI issue is test-only, narrow the rollback to the flaky coverage or replace that coverage with a less brittle regression.
Final Verdict

❌ Changes requested. This revert brings back a real hang in parallel Parquet writes and removes the regression coverage that was proving the fix.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 3, 2026
/// otherwise it may deadlock.
if (!pool->trySchedule(job))
break;
++threads_running;

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.

Removing this line reintroduces the threads_running undercount from #112959. Every worker started through pool->trySchedule(job) still decrements threads_running on exit in threadFunction, so after the first such worker returns the counter can hit 0 or wrap while Parquet tasks are still outstanding. From there the guaranteed scheduleOrThrowOnError path becomes unreachable, and a later trySchedule failure can leave a non-empty task_queue with no worker left to drain it, so finalizeImpl waits forever.

This is not only the deleted fault-injection test: ThreadPool(max_threads) also bounds queue_size to max_threads, so trySchedule can legitimately fail on saturation in production. If the private CI problem is test-only, we need a narrower rollback than dropping the counter fix.

@PedroTadim

Copy link
Copy Markdown
Member

@nikitamikhaylov I was going to create a PR with the fix

@alexey-milovidov

Copy link
Copy Markdown
Member

@alexey-milovidov

Copy link
Copy Markdown
Member

@PedroTadim, always revert first. Fix later.

@alexey-milovidov
alexey-milovidov merged commit e357da5 into master Aug 3, 2026
43 of 60 checks passed
@alexey-milovidov
alexey-milovidov deleted the revert-112959-fix/parquet-parallel-encoder-cancel-hang branch August 3, 2026 18:58
@alexey-milovidov alexey-milovidov self-assigned this Aug 3, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants