diff --git a/plugin/clone/include/clone_client.h b/plugin/clone/include/clone_client.h index da2b4d83719..c100dbfa933 100644 --- a/plugin/clone/include/clone_client.h +++ b/plugin/clone/include/clone_client.h @@ -552,6 +552,10 @@ class Client { /** Change stage in PFS progress table. */ void pfs_change_stage(uint64_t estimate); + /** Add to the data size estimate. + @param[in] estimate_delta how many bytes to add to the estimate */ + void add_to_data_size_estimate(uint64_t estimate_delta); + /** End state in PFS table. @param[in] err_num error number @param[in] err_mesg error message */ @@ -814,6 +818,10 @@ class Client_Cbk : public Ha_clone_cbk { @return error code */ int apply_buffer_cbk(uchar *&to_buffer, uint &len) override; + /** Add to the data size estimate. + @param[in] estimate_delta how many bytes to add to the estimate */ + void add_to_data_size_estimate(uint64_t estimate_delta) override; + private: /** Apply data to local file or buffer. @param[in,out] to_file destination file diff --git a/plugin/clone/include/clone_local.h b/plugin/clone/include/clone_local.h index cd4610e2ba2..2a6268bfce4 100644 --- a/plugin/clone/include/clone_local.h +++ b/plugin/clone/include/clone_local.h @@ -129,6 +129,10 @@ class Local_Callback : public Ha_clone_cbk { @return error code */ int apply_buffer_cbk(uchar *&to_buffer, uint &len) override; + /** Add to the data size estimate. + @param[in] estimate_delta how many bytes to add to the estimate */ + void add_to_data_size_estimate(std::uint64_t estimated_delta) override; + private: /** Apply data using storage engine apply interface. @return error code */ diff --git a/plugin/clone/include/clone_server.h b/plugin/clone/include/clone_server.h index ef38ca89774..45e471ef475 100644 --- a/plugin/clone/include/clone_server.h +++ b/plugin/clone/include/clone_server.h @@ -280,6 +280,13 @@ class Server_Cbk : public Ha_clone_cbk { @return error code */ int apply_buffer_cbk(uchar *&to_buffer, uint &len) override; + /** Callback to update data size estimate for the current SE: not used for + server. + @param[in] estimate_delta how many bytes to add to the estimate */ + void add_to_data_size_estimate(std::uint64_t) override { + assert(0); + } + private: /** Clone server object */ Server *m_clone_server; diff --git a/plugin/clone/include/clone_status.h b/plugin/clone/include/clone_status.h index 3b1f18ec118..32abeead264 100644 --- a/plugin/clone/include/clone_status.h +++ b/plugin/clone/include/clone_status.h @@ -419,6 +419,13 @@ class Progress_pfs : public Table_pfs { write(data_dir); } + /** Add to the data size estimate. + @param[in] estimate_delta how many bytes to add to the estimate */ + void add_to_data_size_estimate(uint64_t estimate) { + assert(m_current_stage != STAGE_NONE); + m_estimate[m_current_stage] += estimate; + } + /** Set PFS table data while ending a Clone stage. @@param[in] data_dir data directory for write. */ void end_stage(bool failed, const char *data_dir) { diff --git a/plugin/clone/src/clone_client.cc b/plugin/clone/src/clone_client.cc index 7fc366c2e95..cdfe844deda 100644 --- a/plugin/clone/src/clone_client.cc +++ b/plugin/clone/src/clone_client.cc @@ -601,6 +601,13 @@ void Client::pfs_change_stage(uint64_t estimate) { mysql_mutex_unlock(&s_table_mutex); } +void Client::add_to_data_size_estimate(uint64_t estimate_delta) { + mysql_mutex_lock(&s_table_mutex); + s_progress_data.add_to_data_size_estimate(estimate_delta); + s_status_data.write(false); + mysql_mutex_unlock(&s_table_mutex); +} + void Client::pfs_end_state(uint32_t err_num, const char *err_mesg) { if (!is_master()) { return; @@ -1780,6 +1787,11 @@ int Client_Cbk::buffer_cbk(uchar *from_buffer [[maybe_unused]], uint buf_len) { return (err); } +void Client_Cbk::add_to_data_size_estimate(std::uint64_t estimate_delta) { + auto *const client = get_clone_client(); + client->add_to_data_size_estimate(estimate_delta); +} + int Client_Cbk::apply_buffer_cbk(uchar *&to_buffer, uint &len) { Ha_clone_file dummy_file; dummy_file.o_direct_uneven_file_size = false; diff --git a/plugin/clone/src/clone_local.cc b/plugin/clone/src/clone_local.cc index cb1b18979a4..b7028b56fc1 100644 --- a/plugin/clone/src/clone_local.cc +++ b/plugin/clone/src/clone_local.cc @@ -252,6 +252,11 @@ int Local_Callback::apply_ack() { return (error); } +void Local_Callback::add_to_data_size_estimate(std::uint64_t estimated_delta) { + auto *const client = get_clone_client(); + client->add_to_data_size_estimate(estimated_delta); +} + int Local_Callback::apply_data() { uint loc_len = 0; diff --git a/sql/handler.h b/sql/handler.h index b88a4888c34..50419116e4f 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1082,6 +1082,10 @@ class Ha_clone_cbk { @return error code */ virtual int apply_buffer_cbk(uchar *&to_buffer, uint &len) = 0; + /** Callback to update clone data size estimate for the current SE. + @param[in] estimate_delta how many bytes to add to the clone size estimate */ + virtual void add_to_data_size_estimate(std::uint64_t estimate_delta) = 0; + /** virtual destructor. */ virtual ~Ha_clone_cbk() = default;