ClickHouse/ClickHouse

[MaterializedPostgreSQL] Error: Columns number mismatch

Aperta

#83.776 aperta il 15 lug 2025

 (3 commenti) (1 reazione) (0 assegnatari)C++ (8400 fork)batch import
help wantedquestion

Metriche repository

Star
 (47.419 stelle)
Metriche merge PR
 (Merge medio 2g 2h) (1000 PR mergiate in 30 g)

Descrizione

Company or project name

No response

Question

ClickHouse server version 25.5.2.47 (official build).

I am using a database with the MaterializedPostgreSQL engine.

I seem to get the following error when a column is added.

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000f88f17b
1. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000009da318c
2. DB::Exception::Exception<unsigned long, unsigned long&>(int, FormatStringHelperImpl<std::type_identity<unsigned long>::type, std::type_identity<unsigned long&>::type>, unsigned long&&, unsigned long&) @ 0x000000000ff4da6b
3. DB::MaterializedPostgreSQLConsumer::StorageData::StorageData(DB::StorageInfo const&, std::shared_ptr<Poco::Logger>) @ 0x0000000012cd6e3c
4. DB::MaterializedPostgreSQLConsumer::MaterializedPostgreSQLConsumer(std::shared_ptr<DB::Context const>, std::shared_ptr<postgres::Connection>, String const&, String const&, String const&, unsigned long, bool, std::unordered_map<String, DB::StorageInfo, std::hash<String>, std::equal_to<String>, std::allocator<std::pair<String const, DB::StorageInfo>>>, String const&) @ 0x0000000012cd482e
5. DB::PostgreSQLReplicationHandler::startSynchronization(bool) @ 0x0000000012caa35a
6. void std::__function::__policy_invoker<void ()>::__call_impl[abi:ne190107]<std::__function::__default_alloc_func<DB::DatabaseMaterializedPostgreSQL::DatabaseMaterializedPostgreSQL(std::shared_ptr<DB::Context const>, String const&, StrongTypedef<wide::integer<128ul, unsigned int>, DB::UUIDTag>, bool, String const&, String const&, postgres::ConnectionInfo const&, std::unique_ptr<DB::MaterializedPostgreSQLSettings, std::default_delete<DB::MaterializedPostgreSQLSettings>>)::$_0, void ()>>(std::__function::__policy_storage const*) @ 0x0000000012ca0ae4
7. DB::BackgroundSchedulePool::threadFunction() @ 0x0000000012761643
8. void std::__function::__policy_invoker<void ()>::__call_impl[abi:ne190107]<std::__function::__default_alloc_func<ThreadFromGlobalPoolImpl<false, true>::ThreadFromGlobalPoolImpl<DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, StrongTypedef<unsigned long, CurrentMetrics::MetricTag>, StrongTypedef<unsigned long, CurrentMetrics::MetricTag>, char const*)::$_1>(DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, StrongTypedef<unsigned long, CurrentMetrics::MetricTag>, StrongTypedef<unsigned long, CurrentMetrics::MetricTag>, char const*)::$_1&&)::'lambda'(), void ()>>(std::__function::__policy_storage const*) @ 0x0000000012762c2a
9. ThreadPoolImpl<std::thread>::ThreadFromThreadPool::worker() @ 0x000000000f9c89b2
10. void* std::__thread_proxy[abi:ne190107]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void (ThreadPoolImpl<std::thread>::ThreadFromThreadPool::*)(), ThreadPoolImpl<std::thread>::ThreadFromThreadPool*>>(void*) @ 0x000000000f9cfe7a
11. ? @ 0x00007cd3c5c9caa4
12. ? @ 0x00007cd3c5d29c3c
 (version 25.5.2.47 (official build))
2025.07.15 10:38:12.155061 [ 1126075 ] {} <Error> DatabaseMaterializedPostgreSQL (prod_replica): Failed to start replication from PostgreSQL, will retry. Error: Code: 49. DB::Exception: Columns number mismatch. Attributes: 14, buffer: 15. (LOGICAL_ERROR), Stack trace (when copying this message, always include the lines below):

I can understand that the problem occurs when the number of columns changes. However, the problem is that I don't know which table has the column mismatch.

Is it possible to figure out which table has the problem in the current structure? If not, it would be good to add a log.

Guida contributor