| 779 | } |
| 780 | |
| 781 | void MaterializeMySQLSyncThread::Buffers::commit(ContextPtr context, const MySQLReplication::Position & position) |
| 782 | { |
| 783 | try |
| 784 | { |
| 785 | if (position.binlog_name.empty()) |
| 786 | throw Exception("binlog is empty when try to committing data for MaterializedMySQL", ErrorCodes::LOGICAL_ERROR); |
| 787 | |
| 788 | MySQLBinLogInfo binlog; |
| 789 | binlog.binlog_file = position.binlog_name; |
| 790 | binlog.binlog_position = position.binlog_pos; |
| 791 | binlog.executed_gtid_set = position.gtid_sets.toString(); |
| 792 | |
| 793 | /// XXX: Here we can just support for one table to flush |
| 794 | for (auto & table_name_and_buffer : data) |
| 795 | { |
| 796 | auto query_context = MaterializedMySQL::createQueryContext(context); |
| 797 | |
| 798 | prepareCommit(query_context, table_name_and_buffer.first + "_" + table_suffix, binlog); |
| 799 | |
| 800 | OneBlockInputStream input(table_name_and_buffer.second->first); |
| 801 | BlockOutputStreamPtr out = getTableOutput(database, table_name_and_buffer.first + "_" + table_suffix, query_context, true); |
| 802 | Stopwatch watch; |
| 803 | copyData(input, *out); |
| 804 | LOG_DEBUG(&Poco::Logger::get("MaterializeMySQLThread ({})"), "Copied {} rows and elapsed {} ms", |
| 805 | table_name_and_buffer.first, table_name_and_buffer.second->first.rows(), watch.elapsedMilliseconds()); |
| 806 | } |
| 807 | |
| 808 | data.clear(); |
| 809 | max_block_rows = 0; |
| 810 | max_block_bytes = 0; |
| 811 | total_blocks_rows = 0; |
| 812 | total_blocks_bytes = 0; |
| 813 | } |
| 814 | catch (...) |
| 815 | { |
| 816 | data.clear(); |
| 817 | throw; |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | MaterializeMySQLSyncThread::Buffers::BufferAndUniqueColumnsPtr MaterializeMySQLSyncThread::Buffers::getTableDataBuffer( |
| 822 | const String & table_name, ContextPtr context) |
no test coverage detected