MCPcopy Create free account
hub / github.com/ByConity/ByConity / commitPosition

Method commitPosition

src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:627–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

625}
626
627void MaterializeMySQLSyncThread::commitPosition(const MySQLReplication::Position & position)
628{
629 if (position.binlog_name.empty())
630 return;
631
632 auto database = DatabaseCatalog::instance().getDatabase(database_name, getContext());
633 auto materialized_mysql = dynamic_cast<DatabaseCloudMaterializedMySQL *>(database.get());
634 if (!materialized_mysql)
635 throw Exception("Expect CloudMaterializedMySQL database, but got " + database->getEngineName(), ErrorCodes::LOGICAL_ERROR);
636
637 String binlog_meta_name = getNameForMaterializedBinlog(materialized_mysql->getDatabaseUUID(), assigned_materialized_table);
638
639 auto binlog_metadata = getContext()->getCnchCatalog()->getMaterializedMySQLBinlogMetadata(binlog_meta_name);
640 if (!binlog_metadata)
641 throw Exception("Cannot get binlog meta from catalog for " + binlog_meta_name, ErrorCodes::LOGICAL_ERROR);
642
643 if (binlog_metadata->binlog_file() != position.binlog_name
644 || binlog_metadata->binlog_position() < position.binlog_pos)
645 {
646 binlog_metadata->set_binlog_file(position.binlog_name);
647 binlog_metadata->set_binlog_position(position.binlog_pos);
648 binlog_metadata->set_executed_gtid_set(position.gtid_sets.toString());
649
650 LOG_DEBUG(log, "Try to commit position while no data in buffers now: {}", dumpPosition(position));
651 getContext()->getCnchCatalog()->setMaterializedMySQLBinlogMetadata(binlog_meta_name, *binlog_metadata);
652 }
653}
654
655void MaterializeMySQLSyncThread::tryCommitPosition(const MySQLReplication::Position & position)
656{

Callers

nothing calls this directly

Calls 12

dumpPositionFunction · 0.85
getDatabaseUUIDMethod · 0.80
ExceptionClass · 0.50
emptyMethod · 0.45
getDatabaseMethod · 0.45
getMethod · 0.45
getEngineNameMethod · 0.45
getCnchCatalogMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected