Skip to content

Commit

Permalink
Bug#32169848 THD_NDB TRANSACTION FUNCTIONALITY [#14]
Browse files Browse the repository at this point in the history
Since table is open when update_stats() is called, the m_share pointer
is always assigned. Remove conditional logic for m_share.

Change-Id: I771a21ed40e95af8782f075b247f22f8635974e4
  • Loading branch information
blaudden committed May 19, 2021
1 parent 300041c commit 0794d39
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions storage/ndb/plugin/ha_ndbcluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12875,18 +12875,16 @@ bool ha_ndbcluster::low_byte_first() const {
@return 0 on success
*/
int ha_ndbcluster::update_stats(THD *thd, bool do_read_stat, uint part_id) {
NDB_SHARE::Table_stats table_stats;
Thd_ndb *thd_ndb = get_thd_ndb(thd);
DBUG_TRACE;
do {
if (m_share && !do_read_stat) {
// Just use the cached stats from NDB_SHARE without reading from NDB
mysql_mutex_lock(&m_share->mutex);
table_stats = m_share->cached_table_stats;
mysql_mutex_unlock(&m_share->mutex);
break;
}

NDB_SHARE::Table_stats table_stats;
if (!do_read_stat) {
// Just use the cached stats from NDB_SHARE without reading from NDB
mysql_mutex_lock(&m_share->mutex);
table_stats = m_share->cached_table_stats;
mysql_mutex_unlock(&m_share->mutex);
} else {
// Request stats from NDB
if (int err =
ndb_get_table_statistics(thd, this, thd_ndb->ndb, m_table,
Expand All @@ -12895,13 +12893,10 @@ int ha_ndbcluster::update_stats(THD *thd, bool do_read_stat, uint part_id) {
}

// Update cached stats in NDB_SHARE with fresh data
if (m_share) {
mysql_mutex_lock(&m_share->mutex);
m_share->cached_table_stats = table_stats;
mysql_mutex_unlock(&m_share->mutex);
}
break;
} while (0);
mysql_mutex_lock(&m_share->mutex);
m_share->cached_table_stats = table_stats;
mysql_mutex_unlock(&m_share->mutex);
}

int no_uncommitted_rows_count = 0;
if (m_table_info && !thd_ndb->m_error) {
Expand Down

0 comments on commit 0794d39

Please sign in to comment.