Skip to content

Commit 85a3695

Browse files
MDEV-27902 Some Spider code documentation regarding first_link_idx and remote HANDLER commands
1 parent 14c4050 commit 85a3695

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

storage/spider/ha_spider.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12918,6 +12918,15 @@ void ha_spider::sync_from_clone_source_base(
1291812918
DBUG_VOID_RETURN;
1291912919
}
1292012920

12921+
/*
12922+
Set the initial values for each dbton_handler's first_link_idx and
12923+
strict_group_by.
12924+
12925+
First, reset first_link_idx to -1.
12926+
Then, for each active remote server, if the corresponding
12927+
dbton_handler has not been set yet (first_link_idx == -1), set its
12928+
first_link_idx to be the index of the connection.
12929+
*/
1292112930
void ha_spider::set_first_link_idx()
1292212931
{
1292312932
int roop_count, all_link_idx;
@@ -12957,6 +12966,16 @@ void ha_spider::set_first_link_idx()
1295712966
DBUG_VOID_RETURN;
1295812967
}
1295912968

12969+
/*
12970+
Reset the initial values for each dbton_handler's first_link_idx to
12971+
-1.
12972+
12973+
Also, set the search_link_idx'th active server's first_link_idx to
12974+
search_link_idx.
12975+
12976+
search_link_idx is commonly randomly set using
12977+
spider_conn_first_link_idx - see the commentary of that function.
12978+
*/
1296012979
void ha_spider::reset_first_link_idx()
1296112980
{
1296212981
int all_link_idx;

storage/spider/ha_spider.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,13 @@ class ha_spider final : public handler
167167
ulonglong *db_request_id;
168168
uchar *db_request_phase;
169169
uchar *m_handler_opened;
170+
/* ids for use in HANDLER command */
170171
uint *m_handler_id;
172+
/*
173+
aliases for use in HANDLER command, in the format of t%5u on
174+
m_handler_id. So for example, if m_handler_id is 3, then the
175+
corresponding m_handler_cid is t00003
176+
*/
171177
char **m_handler_cid;
172178
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
173179
bool do_direct_update;

storage/spider/spd_db_include.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ class spider_db_handler
11351135
uint dbton_id;
11361136
ha_spider *spider;
11371137
spider_db_share *db_share;
1138+
/* Index of active server, used in query construction. */
11381139
int first_link_idx;
11391140
bool strict_group_by= false;
11401141
bool no_where_cond= false;

storage/spider/spd_trx.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,6 +3933,15 @@ void spider_reuse_trx_ha(
39333933
DBUG_VOID_RETURN;
39343934
}
39353935

3936+
/**
3937+
Sets link indices for load balancing read connections
3938+
3939+
Assuming `spider->share->link_count` is the number of active servers
3940+
to use, this function updates `spider->conn_link_idx` with the first
3941+
server in the same "modulus group" whose link status is not
3942+
`SPIDER_LINK_STATUS_NG`, or if one cannot be found, use the
3943+
`link_idx`th server
3944+
*/
39363945
void spider_trx_set_link_idx_for_all(
39373946
ha_spider *spider
39383947
) {

0 commit comments

Comments
 (0)