Skip to content

Revert "Fix DROP TABLE hang on Kafka tables after consumer heartbeat error" - #101646

Merged
alexey-milovidov merged 2 commits into
masterfrom
revert-100388-fix-kafka-consumer-hang-drop-table
Apr 8, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
revert-100388-fix-kafka-consumer-hang-drop-table

Conversation

@azat

@azat azat commented Apr 2, 2026 •

Copy link
Copy Markdown
Member

Reverts #100388

Version info

  • Merged into: 26.4.1.689

@clickhouse-gh

clickhouse-gh Bot commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e74e136]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_tsan, 4/6) failure
test_s3_cluster/test.py::test_select_all FAIL cidb
test_s3_cluster/test.py::test_count FAIL cidb
test_s3_cluster/test.py::test_count_macro FAIL cidb
test_s3_cluster/test.py::test_union_all FAIL cidb
test_s3_cluster/test.py::test_wrong_cluster FAIL cidb
test_s3_cluster/test.py::test_ambiguous_join FAIL cidb
test_s3_cluster/test.py::test_skip_unavailable_shards FAIL cidb
test_s3_cluster/test.py::test_unset_skip_unavailable_shards FAIL cidb
test_s3_cluster/test.py::test_distributed_insert_select_with_replicated FAIL cidb
test_s3_cluster/test.py::test_parallel_distributed_insert_select_with_schema_inference FAIL cidb
8 more test cases not shown
Integration tests (amd_msan, 4/6) failure
test_s3_cluster/test.py::test_select_all FAIL cidb
test_s3_cluster/test.py::test_count FAIL cidb
test_s3_cluster/test.py::test_count_macro FAIL cidb
test_s3_cluster/test.py::test_union_all FAIL cidb
test_s3_cluster/test.py::test_wrong_cluster FAIL cidb
test_s3_cluster/test.py::test_ambiguous_join FAIL cidb
test_s3_cluster/test.py::test_skip_unavailable_shards FAIL cidb
test_s3_cluster/test.py::test_unset_skip_unavailable_shards FAIL cidb
test_s3_cluster/test.py::test_distributed_insert_select_with_replicated FAIL cidb
test_s3_cluster/test.py::test_parallel_distributed_insert_select_with_schema_inference FAIL cidb
8 more test cases not shown

AI Review

Summary

This PR reverts the prior fix for Kafka shutdown handling in StorageKafka::streamToViews. The revert reintroduces two correctness/safety risks: potential DROP TABLE hang during consumer shutdown and offset commit after shutdown-driven interruption that can acknowledge not-fully-processed data. Verdict: request changes.

Findings

❌ Blockers

  • [src/Storages/Kafka/StorageKafka.cpp:722] The revert removes CompletedPipelineExecutor cancellation on shutdown_called, restoring a path where shutdown/DROP TABLE can block waiting for pipeline completion while Kafka polling/rebalance is stuck.
    • Suggested fix: restore a shutdown-aware cancellation callback (or equivalent prompt cancellation mechanism) before executor.execute.
  • [src/Storages/Kafka/StorageKafka.cpp:729] The revert restores unconditional source->commit after execution. If shutdown cancellation interrupts processing, offsets may be committed before all dependent writes complete, risking message loss.
    • Suggested fix: keep a shutdown guard (or equivalent) to skip commits on shutdown cancellation.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ⚠️ Reverting the fix reintroduces shutdown/data-safety risks for Kafka workloads.
Compilation time ✅
Performance & Safety
  • Removing executor cancellation can leave shutdown paths waiting on long Kafka poll/rebalance behavior.
  • Unconditional offset commit after shutdown interruption can violate at-least-once delivery expectations and cause data loss.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    • Restore shutdown-aware cancellation in streamToViews executor path.
    • Restore shutdown-safe commit behavior (do not commit offsets when execution was interrupted by shutdown).

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Apr 2, 2026
/// a heartbeat error.
executor.setCancelCallback([this]() { return shutdown_called.load(); }, 100);

executor.execute();

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.

❌ This revert removes the cancellation callback for CompletedPipelineExecutor. That restores the original deadlock-risk path where DROP TABLE waits for streamToViews while execute can block in Kafka/librdkafka polling during rebalance or heartbeat error handling.

Please keep a shutdown-aware cancellation path (either restore setCancelCallback here or provide an equivalent mechanism) so table shutdown cannot hang indefinitely.

/// as dirty and offsets will remain uncommitted.
if (!shutdown_called)
source->commit();
source->commit();

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.

❌ This revert also restores unconditional source->commit after pipeline execution. During shutdown-driven interruption, committing offsets without guaranteeing the batch reached all dependent views can acknowledge messages that were not fully processed, causing data loss.

Please preserve the shutdown guard (or equivalent logic) that skips commits when shutdown cancellation happened.

@alexey-milovidov

Copy link
Copy Markdown
Member

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

@clickhouse-gh

clickhouse-gh Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.10% +0.10%
Functions 90.90% 90.90% +0.00%
Branches 76.60% 76.60% +0.00%

Changed lines: 100.00% (14/14) | lost baseline coverage: 1 line(s) · Uncovered code

Full report · Diff report

@azat

azat commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

@alexey-milovidov PTAL

@alexey-milovidov alexey-milovidov left a comment

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.

The change is ok, but why did it break integration tests?

@alexey-milovidov alexey-milovidov self-assigned this Apr 8, 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.

3 participants