MDEV-34849 Spider: do not change the first byte of a connection key

Each spider connection is identified with a connection key, which is
an encoding of the backend parameters.

The first byte of the key is by default 0, and in rare circumstances
it is changed to a different value: when semi_table_lock is set to 1;
and when using casual read. When this happens, often a new connection
is created with the new key. Neither case is useful: the description
of semi_table_lock has nothing to do with creation of new connections
and the parameter itself was deprecated for 10.7+ (MDEV-28829) and
marked for deletion (MDEV-28830); while new threads created by
non-zero spider_casual_read causes only threads to be idle, thus not
achieving any gain, see MDEV-26151, and the param has also been
deprecated in 11.5+ (MDEV-31789). The relevant code adds unnecessary
complexity to the spider code. This change does not reduce
parallelism, because already when bgs mode is on a background thread
is created per partition, and there is no evidence spider creates
multiple threads for one partition. If the needs of such cases arise
it will be a separate issue.
This commit is contained in:
Yuchen Pei 2025-01-20 13:41:53 +11:00
parent 7358cbe627
commit 402b1374a7
No known key found for this signature in database
GPG key ID: 3DD1B35105743563
4 changed files with 1 additions and 48 deletions

View file

@ -1006,9 +1006,6 @@ int ha_spider::reset()
THD *thd = ha_thd();
SPIDER_TRX *tmp_trx, *trx_bak;
SPIDER_CONDITION *tmp_cond;
/*
char first_byte, first_byte_bak;
*/
backup_error_status();
DBUG_ENTER("ha_spider::reset");
DBUG_PRINT("info",("spider this=%p", this));

View file

@ -863,17 +863,12 @@ int spider_check_and_get_casual_read_conn(
if (conn->casual_read_current_id > 63)
conn->casual_read_current_id = 2;
}
char first_byte_bak = *spider->conn_keys[link_idx];
*spider->conn_keys[link_idx] =
'0' + spider->result_list.casual_read[link_idx];
if (!(spider->conns[link_idx]= spider_get_conn(
spider->share, link_idx, spider->conn_keys[link_idx],
spider->wide_handler->trx, spider, FALSE, TRUE, &error_num)))
{
*spider->conn_keys[link_idx] = first_byte_bak;
DBUG_RETURN(error_num);
}
*spider->conn_keys[link_idx] = first_byte_bak;
spider->conns[link_idx]->casual_read_base_conn = conn;
spider_check_and_set_autocommit(thd, spider->conns[link_idx], NULL);
DBUG_RETURN(0);

View file

@ -4227,8 +4227,6 @@ SPIDER_SHARE *spider_get_share(
#ifdef WITH_PARTITION_STORAGE_ENGINE
int crd_sync;
#endif
char first_byte;
int semi_table_lock_conn;
int search_link_idx;
uint sql_command = thd_sql_command(thd);
SPIDER_Open_tables_backup open_tables_backup;
@ -4425,13 +4423,6 @@ SPIDER_SHARE *spider_get_share(
pthread_mutex_unlock(&share->mutex);
}
semi_table_lock_conn = spider_param_semi_table_lock_connection(thd,
share->semi_table_lock_conn);
if (semi_table_lock_conn)
first_byte = '0' +
spider_param_semi_table_lock(thd, share->semi_table_lock);
else
first_byte = '0';
if (!(spider->wide_handler->trx = spider_get_trx(thd, TRUE, error_num)))
{
@ -4551,7 +4542,6 @@ SPIDER_SHARE *spider_get_share(
for (roop_count = 0; roop_count < (int) share->link_count; roop_count++)
{
spider->conn_keys[roop_count] = tmp_name;
*tmp_name = first_byte;
tmp_name += share->conn_keys_lengths[roop_count] + 1;
spider->m_handler_cid[roop_count] = tmp_cid;
tmp_cid += SPIDER_SQL_HANDLER_CID_LEN + 1;
@ -4909,14 +4899,6 @@ SPIDER_SHARE *spider_get_share(
pthread_mutex_unlock(&share->mutex);
}
semi_table_lock_conn = spider_param_semi_table_lock_connection(thd,
share->semi_table_lock_conn);
if (semi_table_lock_conn)
first_byte = '0' +
spider_param_semi_table_lock(thd, share->semi_table_lock);
else
first_byte = '0';
spider->share = share;
if (!(spider->wide_handler->trx = spider_get_trx(thd, TRUE, error_num)))
{
@ -5021,7 +5003,6 @@ SPIDER_SHARE *spider_get_share(
for (roop_count = 0; roop_count < (int) share->link_count; roop_count++)
{
spider->conn_keys[roop_count] = tmp_name;
*tmp_name = first_byte;
tmp_name += share->conn_keys_lengths[roop_count] + 1;
spider->m_handler_cid[roop_count] = tmp_cid;
tmp_cid += SPIDER_SQL_HANDLER_CID_LEN + 1;

View file

@ -3411,9 +3411,6 @@ int spider_check_trx_and_get_conn(
SPIDER_TRX *trx;
SPIDER_SHARE *share = spider->share;
SPIDER_CONN *conn;
char first_byte, first_byte_bak;
int semi_table_lock_conn = spider_param_semi_table_lock_connection(thd,
share->semi_table_lock_conn);
DBUG_ENTER("spider_check_trx_and_get_conn");
if (!(trx = spider_get_trx(thd, TRUE, &error_num)))
{
@ -3428,28 +3425,15 @@ int spider_check_trx_and_get_conn(
if (!trx_ha || trx_ha->wait_for_reusing)
spider_trx_set_link_idx_for_all(spider);
if (semi_table_lock_conn)
first_byte = '0' +
spider_param_semi_table_lock(thd, share->semi_table_lock);
else
first_byte = '0';
DBUG_PRINT("info",("spider semi_table_lock_conn = %d",
semi_table_lock_conn));
DBUG_PRINT("info",("spider semi_table_lock = %d",
spider_param_semi_table_lock(thd, share->semi_table_lock)));
DBUG_PRINT("info",("spider first_byte = %d", first_byte));
if (
!trx_ha ||
trx_ha->wait_for_reusing ||
trx->spider_thread_id != spider->spider_thread_id ||
trx->trx_conn_adjustment != spider->trx_conn_adjustment ||
first_byte != *spider->conn_keys[0] ||
share->link_statuses[spider->conn_link_idx[spider->search_link_idx]] ==
SPIDER_LINK_STATUS_NG
) {
DBUG_PRINT("info",(first_byte != *spider->conn_keys[0] ?
"spider change conn type" : trx != spider->wide_handler->trx ?
DBUG_PRINT("info",(trx != spider->wide_handler->trx ?
"spider change thd" : "spider next trx"));
spider->wide_handler->trx = trx;
spider->trx_conn_adjustment = trx->trx_conn_adjustment;
@ -3491,8 +3475,6 @@ int spider_check_trx_and_get_conn(
}
spider->spider_thread_id = trx->spider_thread_id;
first_byte_bak = *spider->conn_keys[0];
*spider->conn_keys[0] = first_byte;
for (roop_count = 0; roop_count < (int) share->link_count; roop_count++)
{
if (!spider->handler_opened(roop_count))
@ -3513,7 +3495,6 @@ int spider_check_trx_and_get_conn(
if (
!spider->conns[roop_count]
) {
*spider->conn_keys[roop_count] = first_byte;
if (
!(conn =
spider_get_conn(share, roop_count,
@ -3543,7 +3524,6 @@ int spider_check_trx_and_get_conn(
);
}
DBUG_PRINT("info",("spider get conn error"));
*spider->conn_keys[0] = first_byte_bak;
spider->spider_thread_id = 0;
DBUG_RETURN(error_num);
}