summaryrefslogtreecommitdiff
path: root/storage/perfschema/table_replication_applier_status_by_worker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/perfschema/table_replication_applier_status_by_worker.cc')
-rw-r--r--storage/perfschema/table_replication_applier_status_by_worker.cc106
1 files changed, 55 insertions, 51 deletions
diff --git a/storage/perfschema/table_replication_applier_status_by_worker.cc b/storage/perfschema/table_replication_applier_status_by_worker.cc
index e4e99dc2325..5eebef920e7 100644
--- a/storage/perfschema/table_replication_applier_status_by_worker.cc
+++ b/storage/perfschema/table_replication_applier_status_by_worker.cc
@@ -1,14 +1,21 @@
/*
- Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
@@ -94,7 +101,7 @@ table_replication_applier_status_by_worker::m_share=
NULL, /* write_row */
NULL, /* delete_all_rows */
table_replication_applier_status_by_worker::get_row_count, /*records*/
- sizeof(PFS_simple_index), /* ref length */
+ sizeof(pos_t), /* ref length */
&m_table_lock,
&m_field_def,
false, /* checked */
@@ -109,8 +116,7 @@ PFS_engine_table* table_replication_applier_status_by_worker::create(void)
table_replication_applier_status_by_worker
::table_replication_applier_status_by_worker()
: PFS_engine_table(&m_share, &m_pos),
- m_row_exists(false), m_pos(), m_next_pos(),
- m_applier_pos(0), m_applier_next_pos(0)
+ m_row_exists(false), m_pos(), m_next_pos()
{}
table_replication_applier_status_by_worker
@@ -121,8 +127,6 @@ void table_replication_applier_status_by_worker::reset_position(void)
{
m_pos.reset();
m_next_pos.reset();
- m_applier_pos.m_index=0;
- m_applier_next_pos.m_index=0;
}
ha_rows table_replication_applier_status_by_worker::get_row_count()
@@ -138,52 +142,47 @@ int table_replication_applier_status_by_worker::rnd_next(void)
{
Slave_worker *worker;
Master_info *mi;
- int res= HA_ERR_END_OF_FILE;
+ size_t wc;
channel_map.rdlock();
- /*
- For each SQL Thread in all channels get the respective Master_info and
- construct a row to display its status in
- 'replication_applier_status_by_worker' table in case of single threaded
- slave mode.
- */
- for(m_applier_pos.set_at(&m_applier_next_pos);
- m_applier_pos.m_index < channel_map.get_max_channels();
- m_applier_pos.next())
- {
- mi= channel_map.get_mi_at_pos(m_applier_pos.m_index);
-
- if (mi && mi->host[0] && mi->rli && mi->rli->get_worker_count()==0)
- {
- make_row(mi);
- m_applier_next_pos.set_after(&m_applier_pos);
-
- channel_map.unlock();
- return 0;
- }
- }
-
for (m_pos.set_at(&m_next_pos);
- m_pos.has_more_channels(channel_map.get_max_channels()) && res != 0;
+ m_pos.has_more_channels(channel_map.get_max_channels());
m_pos.next_channel())
{
mi= channel_map.get_mi_at_pos(m_pos.m_index_1);
if (mi && mi->host[0])
{
- worker= mi->rli->get_worker(m_pos.m_index_2);
- if (worker)
+ wc= mi->rli->get_worker_count();
+
+ if (wc == 0)
{
- make_row(worker);
- m_next_pos.set_after(&m_pos);
- res= 0;
+ /* Single Thread Slave */
+ make_row(mi);
+ m_next_pos.set_channel_after(&m_pos);
+ channel_map.unlock();
+ return 0;
+ }
+
+ for (; m_pos.m_index_2 < wc; m_pos.next_worker())
+ {
+ /* Multi Thread Slave */
+
+ worker = mi->rli->get_worker(m_pos.m_index_2);
+ if (worker)
+ {
+ make_row(worker);
+ m_next_pos.set_after(&m_pos);
+ channel_map.unlock();
+ return 0;
+ }
}
}
}
channel_map.unlock();
- return res;
+ return HA_ERR_END_OF_FILE;
}
int table_replication_applier_status_by_worker::rnd_pos(const void *pos)
@@ -191,6 +190,7 @@ int table_replication_applier_status_by_worker::rnd_pos(const void *pos)
Slave_worker *worker;
Master_info *mi;
int res= HA_ERR_RECORD_DELETED;
+ size_t wc;
set_position(pos);
@@ -201,22 +201,26 @@ int table_replication_applier_status_by_worker::rnd_pos(const void *pos)
if (!mi || !mi->rli || !mi->host[0])
goto end;
- DBUG_ASSERT(m_pos.m_index_1 < mi->rli->get_worker_count());
- /*
- Display SQL Thread's status only in the case of single threaded mode.
- */
- if (mi->rli->get_worker_count() == 0)
+ wc = mi->rli->get_worker_count();
+
+ if (wc == 0)
{
+ /* Single Thread Slave */
make_row(mi);
- res= 0;
- goto end;
+ res=0;
}
- worker= mi->rli->get_worker(m_pos.m_index_2);
-
- if (worker != NULL)
+ else
{
- make_row(worker);
- res= 0;
+ /* Multi Thread Slave */
+ if (m_pos.m_index_2 < wc)
+ {
+ worker = mi->rli->get_worker(m_pos.m_index_2);
+ if (worker != NULL)
+ {
+ make_row(worker);
+ res=0;
+ }
+ }
}
end: