Merge pull request #14696 from BohuTANG/mysql_replication_tablemapevent

Fix mysql replication optional metadata ignore
This commit is contained in:
tavplubix 2020-09-11 15:09:55 +03:00 committed by GitHub
commit 92eb58b555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 16 deletions

View File

@ -50,21 +50,22 @@ uint64_t readLengthEncodedNumber(ReadBuffer & buffer)
uint64_t buf = 0;
buffer.readStrict(c);
auto cc = static_cast<uint8_t>(c);
if (cc < 0xfc)
switch (cc)
{
return cc;
}
else if (cc < 0xfd)
{
buffer.readStrict(reinterpret_cast<char *>(&buf), 2);
}
else if (cc < 0xfe)
{
buffer.readStrict(reinterpret_cast<char *>(&buf), 3);
}
else
{
buffer.readStrict(reinterpret_cast<char *>(&buf), 8);
/// NULL
case 0xfb:
break;
case 0xfc:
buffer.readStrict(reinterpret_cast<char *>(&buf), 2);
break;
case 0xfd:
buffer.readStrict(reinterpret_cast<char *>(&buf), 3);
break;
case 0xfe:
buffer.readStrict(reinterpret_cast<char *>(&buf), 8);
break;
default:
return cc;
}
return buf;
}

View File

@ -171,7 +171,7 @@ namespace MySQLReplication
/// Ignore MySQL 8.0 optional metadata fields.
/// https://mysqlhighavailability.com/more-metadata-is-written-into-binary-log/
payload.ignore(payload.available() - CHECKSUM_CRC32_SIGNATURE_LENGTH);
payload.ignoreAll();
}
/// Types that do not used in the binlog event:
@ -221,6 +221,7 @@ namespace MySQLReplication
}
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_STRING: {
/// Big-Endian
auto b0 = UInt16(meta[pos] << 8);
auto b1 = UInt8(meta[pos + 1]);
column_meta.emplace_back(UInt16(b0 + b1));
@ -231,6 +232,7 @@ namespace MySQLReplication
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_VAR_STRING: {
/// Little-Endian
auto b0 = UInt8(meta[pos]);
auto b1 = UInt16(meta[pos + 1] << 8);
column_meta.emplace_back(UInt16(b0 + b1));
@ -911,7 +913,7 @@ namespace MySQLReplication
break;
}
}
payload.tryIgnore(CHECKSUM_CRC32_SIGNATURE_LENGTH);
payload.ignoreAll();
}
}

View File

@ -283,6 +283,7 @@ int main(int argc, char ** argv)
}
{
/// mysql_protocol --host=172.17.0.3 --user=root --password=123 --db=sbtest
try
{
boost::program_options::options_description desc("Allowed options");

View File

@ -195,6 +195,7 @@ void MaterializeMySQLSyncThread::synchronization(const String & mysql_version)
}
catch (...)
{
client.disconnect();
tryLogCurrentException(log);
getDatabase(database_name).setException(std::current_exception());
}
@ -206,6 +207,7 @@ void MaterializeMySQLSyncThread::stopSynchronization()
{
sync_quit = true;
background_thread_pool->join();
client.disconnect();
}
}