| 625 | } |
| 626 | |
| 627 | void 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 | |
| 655 | void MaterializeMySQLSyncThread::tryCommitPosition(const MySQLReplication::Position & position) |
| 656 | { |
nothing calls this directly
no test coverage detected