Skip to content

Fix the table name used by MaterializedPostgreSQL for the Relation message in multi-schema mode - #125952

Merged
alexey-milovidov merged 9 commits into
masterfrom
mpg-consumer-sync-allowed-key
Oct 30, 2026
Merged

alexey-milovidov merged 9 commits into
masterfrom
mpg-consumer-sync-allowed-key

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Related: #110493

MaterializedPostgreSQLConsumer::isSyncAllowed looks a table up in deleted_tables and waiting_list, which are keyed by the ClickHouse table name. In the multi-schema modes (materialized_postgresql_schema_list, or materialized_postgresql_tables_list_with_schema) that name includes the PostgreSQL schema (schema.table). The Insert, Update and Delete messages already pass that name, but the Relation message passed the bare PostgreSQL relation name, so the lookup always missed in those modes.

The visible consequence: after DETACH TABLE ... PERMANENTLY in a multi-schema database, a Relation message for that table still in the replication stream was not recognized as belonging to a deleted table. The consumer logged a misleading Storage for table ... does not exist, but is included in replication stream error and put the table into the skip list (the entry is cleared again by a later ATTACH TABLE). Data was not affected, because the subsequent Insert/Update/Delete messages use the correct key. The change was split out of #110493.

No test is added: the only observable effect is a log message, and reproducing it requires the Relation message to arrive after the DETACH TABLE ... PERMANENTLY, which cannot be arranged deterministically without timing assumptions. For this reason the change is categorized as an improvement rather than a bug fix, which would require a regression test.

Changelog category (leave one):

  • Improvement

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

Fixed a misleading error Storage for table ... does not exist, but is included in replication stream logged by a MaterializedPostgreSQL database with materialized_postgresql_schema_list or materialized_postgresql_tables_list_with_schema after DETACH TABLE ... PERMANENTLY.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/125952]

Version info

  • Merged into: 26.11.1.908-master (included in 26.11 and later)

…essage

`deleted_tables` and `waiting_list` of `MaterializedPostgreSQLConsumer` are keyed by the
ClickHouse table name, which includes the PostgreSQL schema when
`materialized_postgresql_schema_list` or `materialized_postgresql_tables_list_with_schema`
is used. The `Insert`, `Update` and `Delete` messages already pass that name, but the
`Relation` message passed the bare PostgreSQL relation name. So in the multi-schema modes
a table removed with `DETACH TABLE ... PERMANENTLY` was not recognized as deleted when its
`Relation` message was still in the replication stream: the consumer logged a misleading
error that the storage does not exist and put the table into the skip list.

Related: #110493

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9a82518]

Summary: ✅


AI Review

Summary

Relation messages now pass the ClickHouse table name to MaterializedPostgreSQLConsumer::isSyncAllowed, matching the keys in deleted_tables and waiting_list in both multi-schema modes. This prevents misleading missing-storage errors after DETACH TABLE ... PERMANENTLY. No actionable findings. The documented exception to adding a timing-dependent, log-only regression test is reasonable for this narrow change.

Missing context / blind spots
  • ⚠️ Full CI for head 9a82518e305720fc0f38df0feb1c440fce3b9e7a is still in progress. No local build or integration tests were run; completed PostgreSQL integration results would close the runtime verification gap.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-postgresql PostgreSQL-specific integration (table engine/function, logical replication bridge). labels Oct 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 9a82518e3 with master 7fc4e86ed (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged the latest master (no conflicts; MaterializedPostgreSQLConsumer.cpp builds). The only red check was new_tests_check.py in Finish Workflow ("No new tests have been added" for a pr-bugfix PR). Everything else passed.

I did not add a test. The only effect of the fix is that a misleading LOG_ERROR no longer appears. The stale skip_list entry it used to create is already removed by addNested on the next ATTACH TABLE, so nothing else changes that a test could check. To reproduce it you would need a Relation message decoded after DETACH TABLE ... PERMANENTLY, and the only assertion left would be the absence of a log line. The test guidelines advise against that kind of integration test.

A maintainer needs to decide: accept the red test gate as it is, or change the changelog category (for example to Improvement) so the gate does not apply.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged the latest master to pick up c14207b, which fixes the arm_tidy build failure in gtest_functions_stress.cpp (unrelated to this PR, caused by the StackTrace::tryResolveAddress API change). MaterializedPostgreSQLConsumer.cpp builds after the merge. The other red check, new_tests_check.py, is the expected "no new tests" result, explained in the PR description and my earlier comment.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged the latest master (no conflicts; MaterializedPostgreSQLConsumer.cpp builds). This pulls in #126345, which fixes the flaky 03821_drop_workload_during_query_race. That test failed here in Stateless tests (arm_asan_ubsan, azure, sequential, 2/2) and is unrelated to this PR. The other red check is still new_tests_check.py ("No new tests have been added"). The PR description explains why there is no test: the only effect is a log line, and it cannot be reproduced deterministically. A maintainer needs to accept that, or change the changelog category.

@alexey-milovidov alexey-milovidov added pr-improvement Pull request with some product improvements and removed pr-bugfix Pull request with bugfix, not backported by default labels Oct 25, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The only red check was new_tests_check (Bug Fix category without a regression test). The only observable effect of this fix is a misleading log message, and reproducing it needs a Relation message to arrive after DETACH TABLE ... PERMANENTLY, which can't be arranged deterministically. So I changed the changelog category to Improvement (label pr-improvement) rather than adding a timing-dependent integration test, and merged master to start a fresh CI run.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged the latest master (no conflicts, PR diff unchanged). Both red checks are unrelated to this PR: 05218_text_index_substreams_opened_lazily is fixed on master by 4649977 (pulled in by this merge), and 03254_prewarm_mark_cache_rmt is flaky (1/23 reruns failed) with a fix in progress in #127866.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 None of the three red checks comes from this PR (it changes one line in MaterializedPostgreSQLConsumer.cpp):

The branch already includes master from 2026-10-27. Neither fix has merged yet, so I didn't merge master again.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged the latest master (no conflicts, PR diff unchanged, nothing under src/Storages/PostgreSQL/ changed on master). This pulls in the fixes for two of the three unrelated red checks: #127866 (03254_prewarm_mark_cache_rmt) and #128067 (Build profile diff with LogClusterNotReady). The third, 04813_gcd_codec_hash_signedness, is being fixed in #128024.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged the latest master (no conflicts, PR diff unchanged, MaterializedPostgreSQLConsumer.cpp builds) to re-run CI.

The only red check on 7413d91 was 05453_webterminal_close_at_binary_format_question in Stateless tests (amd_debug, parallel) (with the derived "Some queries hung"): after closing the web terminal at the binary-format question, the query was still in system.processes. It is unrelated to this PR, and it failed in at least 7 other PRs on 2026-10-28 and 2026-10-29 (119664, 124882, 113173, 122822, 126012, 122580, 112351).

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125952&sha=7413d91dbea5c81f14c8ce6c5bcd498e357c066c&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. (These may be related: #127913 and #128090.)

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is already in progress: #126995 (mine, open, mergeable, waiting for a review).

This run hangs for the same reason as 05386_webterminal_close_during_query: a process started by the server inherited the pseudo-terminal. The server log of this job:

  • the web terminal session of 05453 starts at 01:30:02.758 (server time);
  • 05394_executable_pool_does_not_keep_closed_connection_open runs in parallel, and its dictGet starts the executable_pool process /bin/sh (pid 437496) at 01:30:03.635;
  • the WebSocket closes at 01:30:03.806 (Closing server descriptors and waiting for client to finish), and the client never finishes.

openPty opens the pseudo-terminal without O_CLOEXEC, so pid 437496 keeps a copy of the master. Closing it in the server does not hang up the slave, so the embedded client stays blocked in read() inside ask() (hung-query stack: ReadBufferFromFileDescriptor::readImpl <- readStringUntilCharsInto <- DB::ask <- ClientBase::initOutputFormat), and the HTTP handler waits in ~ClientEmbeddedRunner. #126995 opens both ends with O_CLOEXEC, and Poco pipes with pipe2(O_CLOEXEC) for the same problem over SSH.

The two other PRs:

@alexey-milovidov alexey-milovidov left a comment

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.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Oct 30, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The minimal change can go without new tests.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 30, 2026
zoomxi pushed a commit to zoomxi/ClickHouse that referenced this pull request Oct 30, 2026
…anularity_bytes`

With a small randomized `index_granularity_bytes` (e.g. 4497), adaptive
granularity gives the combined two-column table granules with half as many
rows as the single-column tables, so its compressed blocks are smaller and
compress worse, and the 5% size bound is exceeded. Pin
`index_granularity_bytes` to the default in all three tables.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125952&sha=d0a72c3189ee40f5727ba0189b3f36597b852544&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20AsyncInsert%2C%20s3%20storage%2C%20parallel%29
PR: ClickHouse#125952

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged via the queue into master with commit 48385ad Oct 30, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the mpg-consumer-sync-allowed-key branch October 30, 2026 08:22
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-postgresql PostgreSQL-specific integration (table engine/function, logical replication bridge). 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