
It seems MaterializeMySQL not able to handle below bin log events, hence cause exception, the problem is high frequency occur of the exception may cause MaterializeMySQLSyncThread crash (I guess, the phenomenon is the synced DB in ClickHouse is not accessible)

My suggestion is, if such log event is harmless, we just skip it.

> #200829 16:15:00 server id 936  end_log_pos 710243420 CRC32 0x0fe88b7e  Xid = 13469366
> COMMIT/*!*/;

Exception:

> 2020.08.29 16:41:02.696328 [ 104835 ] {} <Error> MaterializeMySQLSyncThread(): Query EXTERNAL DDL FROM MySQL(host_monitor, host_monitor) COMMIT wasn't finished successfully: Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 115 ('COMMIT'): COMMIT. Expected one of: RENAME DATABASE, TRUNCATE, RENAME TABLE, DROP query, RENAME DICTIONARY, DETACH, RENAME query, DROP, create query, CREATE, EXCHANGE TABLES, ALTER TABLE, alter query, Stack trace (when copying this message, always include the lines below):
> 
> 0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x1a7d7400 in /usr/bin/clickhouse
> 1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0xff8f78d in /usr/bin/clickhouse
> 2. ? @ 0x183f6741 in /usr/bin/clickhouse
> 3. ? @ 0x177a3d6e in /usr/bin/clickhouse
> 4. DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool) @ 0x177a5e7f in /usr/bin/clickhouse
> 5. ? @ 0x17367e84 in /usr/bin/clickhouse
> 6. DB::MaterializeMySQLSyncThread::onEvent(DB::MaterializeMySQLSyncThread::Buffers&, std::__1::shared_ptr<DB::MySQLReplication::EventBase> const&, DB::MaterializeMetadata&) @ 0x1736ee86 in /usr/bin/clickhouse
> 7. DB::MaterializeMySQLSyncThread::synchronization(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0x173707bf in /usr/bin/clickhouse
> 8. ? @ 0x17370ba6 in /usr/bin/clickhouse
> 9. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xffbf517 in /usr/bin/clickhouse
> 10. ? @ 0xffbdb53 in /usr/bin/clickhouse
> 11. start_thread @ 0x7dd5 in /usr/lib64/libpthread-2.17.so
> 12. clone @ 0xfdead in /usr/lib64/libc-2.17.so
>  (version 20.8.1.4474 (official build))
> 2020.08.29 16:41:02.696498 [ 104835 ] {} <Error> MaterializeMySQLSyncThread: Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 115 ('COMMIT'): COMMIT. Expected one of: RENAME DATABASE, TRUNCATE, RENAME TABLE, DROP query, RENAME DICTIONARY, DETACH, RENAME query, DROP, create query, CREATE, EXCHANGE TABLES, ALTER TABLE, alter query, Stack trace (when copying this message, always include the lines below):
> 
> 0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x1a7d7400 in /usr/bin/clickhouse
> 1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0xff8f78d in /usr/bin/clickhouse
> 2. ? @ 0x183f6741 in /usr/bin/clickhouse
> 3. ? @ 0x177a3d6e in /usr/bin/clickhouse
> 4. DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool) @ 0x177a5e7f in /usr/bin/clickhouse
> 5. ? @ 0x17367e84 in /usr/bin/clickhouse
> 6. DB::MaterializeMySQLSyncThread::onEvent(DB::MaterializeMySQLSyncThread::Buffers&, std::__1::shared_ptr<DB::MySQLReplication::EventBase> const&, DB::MaterializeMetadata&) @ 0x1736ee86 in /usr/bin/clickhouse
> 7. DB::MaterializeMySQLSyncThread::synchronization(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0x173707bf in /usr/bin/clickhouse
> 8. ? @ 0x17370ba6 in /usr/bin/clickhouse
> 9. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xffbf517 in /usr/bin/clickhouse
> 10. ? @ 0xffbdb53 in /usr/bin/clickhouse
> 11. start_thread @ 0x7dd5 in /usr/lib64/libpthread-2.17.so
> 12. clone @ 0xfdead in /usr/lib64/libc-2.17.so
>  (version 20.8.1.4474 (official build))

**Additional context**
I'm using MySQL slave as the source of ClickHouse

{
        header.dump(out);
        out << "Position: " << this->position << std::endl;
        out << "Next Binlog: " << this->next_binlog << std::endl;
    }
    
    void QueryEvent::parseImpl(ReadBuffer & payload)
    {
        payload.readStrict(reinterpret_cast<char *>(&thread_id), 4);
        payload.readStrict(reinterpret_cast<char *>(&exec_time), 4);
        payload.readStrict(reinterpret_cast<char *>(&schema_len), 1);
        payload.readStrict(reinterpret_cast<char *>(&error_code), 2);
        payload.readStrict(reinterpret_cast<char *>(&status_len), 2);
        status.resize(status_len);
        payload.readStrict(reinterpret_cast<char *>(status.data()), status_len);
        schema.resize(schema_len);
        payload.readStrict(reinterpret_cast<char *>(schema.data()), schema_len);
        payload.ignore(1);
        size_t len
            = header.event_size - EVENT_HEADER_LENGTH - 4 - 4 - 1 - 2 - 2 - status_len - schema_len - 1 - CHECKSUM_CRC32_SIGNATURE_LENGTH;
        query.resize(len);
        payload.readStrict(reinterpret_cast<char *>(query.data()), len);
        if (query.rfind("BEGIN", 0) == 0)
        {
            typ = BEGIN;
        }
        else if (query.rfind("XA", 0) == 0)
        {
            if (query.rfind("XA ROLLBACK", 0) == 0)