ClickHouse: 22.3.3.44
CentOS Linux release 7.8.2003 (Core)
PostgreSQL: 12.5

ClickHouse crashes while creating an external dictionary with PostgreSQL 12.5 as a source.  Client returns Unexpected EOF while reading bytes message after query finish.
```
CREATE DICTIONARY xxx_dict (
    id String,
    x1 String,
    x2 String,
    x3_time Datetime,
    x4_by String,
    x5_time Datetime,
    x7_time Datetime,
    x8 String,
    x9 Array(String)
)PRIMARY KEY id
SOURCE(POSTGRESQL(
    port 5432
    host 'x.x.x.x'
    user 'xxx'
    password 'xxx'
    db 'xxx'
    table 'xx_table'
    invalidate_query 'SELECT x3_time,x5_time FROM xx_table order by x3_time desc,x5_time desc limit 1'))
LAYOUT(COMPLEX_KEY_HASHED())
LIFETIME(MIN 100 MAX 120);
```

Crash logs from /var/log/clickhouse-server/clickhouse-server.err.log
```
2022.04.11 08:55:05.679971 [ 23405 ] {} <Fatal> BaseDaemon: ########################################
2022.04.11 08:55:05.680043 [ 23405 ] {} <Fatal> BaseDaemon: (version 22.3.3.44 (official build), build id: F9D3C2B8666BEF5D) (from thread 5319) (no query) Received signal Segmentation fault (11)
2022.04.11 08:55:05.680095 [ 23405 ] {} <Fatal> BaseDaemon: Address: NULL pointer. Access: read. Unknown si_code.
2022.04.11 08:55:05.680205 [ 23405 ] {} <Fatal> BaseDaemon: Stack trace: 0xb34e02b 0x168fc2b5 0x168fbe7a 0x16b53782 0x1691c603 0x1691005e 0x1690f880 0x1692112e 0x1692148c 0x12916eab 0x12965bd7 0x12965645 0x1297b4e8 0x157d6240 0x157d5b19 0x157d7b97 0xb418757 0xb41c2dd 0x7fb704847ea5 0x7fb7045708dd
2022.04.11 08:55:05.680297 [ 23405 ] {} <Fatal> BaseDaemon: 2. DB::PostgreSQLSource<pqxx::transaction<(pqxx::isolation_level)0, (pqxx::write_policy)0> >::generate() @ 0xb34e02b in /usr/bin/clickhouse
2022.04.11 08:55:05.680334 [ 23405 ] {} <Fatal> BaseDaemon: 3. DB::ISource::tryGenerate() @ 0x168fc2b5 in /usr/bin/clickhouse
2022.04.11 08:55:05.680357 [ 23405 ] {} <Fatal> BaseDaemon: 4. DB::ISource::work() @ 0x168fbe7a in /usr/bin/clickhouse
2022.04.11 08:55:05.680381 [ 23405 ] {} <Fatal> BaseDaemon: 5. DB::SourceWithProgress::work() @ 0x16b53782 in /usr/bin/clickhouse
2022.04.11 08:55:05.680404 [ 23405 ] {} <Fatal> BaseDaemon: 6. DB::ExecutionThreadContext::executeTask() @ 0x1691c603 in /usr/bin/clickhouse
2022.04.11 08:55:05.680445 [ 23405 ] {} <Fatal> BaseDaemon: 7. DB::PipelineExecutor::executeStepImpl(unsigned long, std::__1::atomic<bool>*) @ 0x1691005e in /usr/bin/clickhouse
2022.04.11 08:55:05.680472 [ 23405 ] {} <Fatal> BaseDaemon: 8. DB::PipelineExecutor::executeStep(std::__1::atomic<bool>*) @ 0x1690f880 in /usr/bin/clickhouse
2022.04.11 08:55:05.680497 [ 23405 ] {} <Fatal> BaseDaemon: 9. DB::PullingPipelineExecutor::pull(DB::Chunk&) @ 0x1692112e in /usr/bin/clickhouse
2022.04.11 08:55:05.680520 [ 23405 ] {} <Fatal> BaseDaemon: 10. DB::PullingPipelineExecutor::pull(DB::Block&) @ 0x1692148c in /usr/bin/clickhouse
2022.04.11 08:55:05.680574 [ 23405 ] {} <Fatal> BaseDaemon: 11. DB::readInvalidateQuery(DB::QueryPipeline) @ 0x12916eab in /usr/bin/clickhouse
2022.04.11 08:55:05.680608 [ 23405 ] {} <Fatal> BaseDaemon: 12. DB::PostgreSQLDictionarySource::doInvalidateQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const @ 0x12965bd7 in /usr/bin/clickhouse
2022.04.11 08:55:05.680631 [ 23405 ] {} <Fatal> BaseDaemon: 13. DB::PostgreSQLDictionarySource::isModified() const @ 0x12965645 in /usr/bin/clickhouse
2022.04.11 08:55:05.680670 [ 23405 ] {} <Fatal> BaseDaemon: 14. DB::IDictionary::isModified() const @ 0x1297b4e8 in /usr/bin/clickhouse
2022.04.11 08:55:05.680696 [ 23405 ] {} <Fatal> BaseDaemon: 15. DB::ExternalLoader::LoadingDispatcher::reloadOutdated() @ 0x157d6240 in /usr/bin/clickhouse
2022.04.11 08:55:05.680717 [ 23405 ] {} <Fatal> BaseDaemon: 16. DB::ExternalLoader::PeriodicUpdater::doPeriodicUpdates() @ 0x157d5b19 in /usr/bin/clickhouse
2022.04.11 08:55:05.680761 [ 23405 ] {} <Fatal> BaseDaemon: 17. ThreadFromGlobalPool::ThreadFromGlobalPool<void (DB::ExternalLoader::PeriodicUpdater::*)(), DB::ExternalLoader::PeriodicUpdater*>(void (DB::ExternalLoader::PeriodicUpdater::*&&)(), DB::ExternalLoader::PeriodicUpdater*&&)::'lambda'()::operator()() @ 0x157d7b97 in /usr/bin/clickhouse
2022.04.11 08:55:05.680798 [ 23405 ] {} <Fatal> BaseDaemon: 18. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xb418757 in /usr/bin/clickhouse
2022.04.11 08:55:05.680822 [ 23405 ] {} <Fatal> BaseDaemon: 19. ? @ 0xb41c2dd in /usr/bin/clickhouse
2022.04.11 08:55:05.680851 [ 23405 ] {} <Fatal> BaseDaemon: 20. start_thread @ 0x7ea5 in /usr/lib64/libpthread-2.17.so
2022.04.11 08:55:05.680881 [ 23405 ] {} <Fatal> BaseDaemon: 21. clone @ 0xfe8dd in /usr/lib64/libc-2.17.so
2022.04.11 08:55:06.066945 [ 23405 ] {} <Fatal> BaseDaemon: Calculated checksum of the binary: FD20C2FC24F8B8996C15BF97FA841B03. There is no information about the reference checksum.
```



PostgreSQL logs
```
2022-04-11 16:59:00.916 CST [421] LOG:  unexpected EOF on client connection with an open transaction
```
I have looked at these issues but no solution.save the child, thank you.

https://github.com/ClickHouse/ClickHouse/issues/32991
https://github.com/ClickHouse/ClickHouse/issues/36030


postgres::ConnectionHolderPtr connection_holder_,
    const std::string & query_str_,
    const Block & sample_block,
    UInt64 max_block_size_)
    : ISource(sample_block.cloneEmpty())
    , query_str(query_str_)
    , max_block_size(max_block_size_)
    , connection_holder(std::move(connection_holder_))
{
    init(sample_block);
}
template<typename T>
PostgreSQLSource<T>::PostgreSQLSource(