Skip to content

Fix crash when attaching table to MaterializedPostgreSQL database#96871

Merged
alexey-milovidov merged 2 commits intomasterfrom
fix-materialized-postgresql-attach-crash
Feb 15, 2026
Merged

Fix crash when attaching table to MaterializedPostgreSQL database#96871
alexey-milovidov merged 2 commits intomasterfrom
fix-materialized-postgresql-attach-crash

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

@alexey-milovidov alexey-milovidov commented Feb 14, 2026

Summary

  • Fix fatal server crash (std::terminate) when attaching a table to a MaterializedPostgreSQL database
  • The TemporaryReplicationSlot destructor called dropReplicationSlot without exception handling; if an exception was already in flight (e.g. from loadFromSnapshot) and dropReplicationSlot also threw (pqxx::sql_error: replication slot does not exist), having two exceptions caused std::terminate
  • Wrap the destructor body in try-catch, following the C++ rule that destructors must not throw

Closes #62711

Changelog category (leave one):

  • Improvement

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

Fix crash when attaching a table to a MaterializedPostgreSQL database if dropReplicationSlot throws during stack unwinding.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

The `TemporaryReplicationSlot` destructor called `dropReplicationSlot`
without exception handling. If an error occurred during
`addTableToReplication` (e.g., `loadFromSnapshot` failed), C++ stack
unwinding would invoke this destructor. If `dropReplicationSlot` also
threw (e.g., `pqxx::sql_error`: replication slot does not exist),
having two exceptions in flight caused `std::terminate`, killing the
server process.

Wrap the destructor body in a try-catch to prevent exceptions from
propagating, following the C++ rule that destructors must not throw.

Closes #62711

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 14, 2026

Workflow [PR], commit [e0adc73]

Summary:

job_name test_name status info comment
Stateless tests (amd_binary, old analyzer, s3 storage, DatabaseReplicated, sequential) failure
01079_parallel_alter_detach_table_zookeeper FAIL cidb, issue

@clickhouse-gh clickhouse-gh bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Feb 14, 2026
@alexey-milovidov alexey-milovidov added pr-improvement Pull request with some product improvements and removed pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-critical-bugfix labels Feb 14, 2026
@alexey-milovidov alexey-milovidov merged commit e650320 into master Feb 15, 2026
132 of 135 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-materialized-postgresql-attach-crash branch February 15, 2026 00:15
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 15, 2026
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.

Fatal error while attaching table with MaterializedPostgreSQL

2 participants