From 433a0d355388f5f8f573d9f53da374de74700936 Mon Sep 17 00:00:00 2001 From: qiuyang19960521 Date: Thu, 14 Nov 2024 20:52:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(chore):=20=E7=94=9F=E6=80=81=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=96=AD=E8=A8=80=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage/ctc/ctc_cbo.cc | 6 +-- storage/ctc/ctc_ddl_rewriter_plugin.cc | 13 +++--- storage/ctc/ctc_ddl_util.cc | 11 +++--- storage/ctc/ctc_log.h | 8 ++++ storage/ctc/ctc_meta_data.cc | 32 +++++++-------- storage/ctc/ctc_mysql_proxy.cc | 5 +-- storage/ctc/ctc_srv_mq_module.cc | 5 +-- storage/ctc/ctc_srv_mq_stub.cc | 55 +++++++++++++++++--------- storage/ctc/ctc_util.cc | 3 +- storage/ctc/datatype_cnvrtr.cc | 3 +- storage/ctc/ha_ctc.cc | 5 +-- 11 files changed, 83 insertions(+), 63 deletions(-) diff --git a/storage/ctc/ctc_cbo.cc b/storage/ctc/ctc_cbo.cc index 2687648..7f26377 100644 --- a/storage/ctc/ctc_cbo.cc +++ b/storage/ctc/ctc_cbo.cc @@ -331,8 +331,7 @@ double calc_hist_equal_density(ctc_cbo_stats_table_t *cbo_stats, cache_variant_t return density; } if (hist_count > STATS_HISTGRAM_MAX_SIZE) { - ctc_log_error("Error hist_count: %u, column id: %u", hist_count, col_id); - assert(0); + assert_log(0, "Error hist_count: %u, column id: %u", hist_count, col_id); return col_stat->density; } @@ -552,8 +551,7 @@ static double calc_hist_between_density(ctc_cbo_stats_table_t *cbo_stats, return col_stat->density; } if (col_stat->hist_count > STATS_HISTGRAM_MAX_SIZE) { - ctc_log_error("Error hist_count: %u, column id: %u", col_stat->hist_count, col_id); - assert(0); + assert_log(0, "Error hist_count: %u, column id: %u", col_stat->hist_count, col_id); return col_stat->density; } if (col_stat->hist_type == FREQUENCY_HIST) { diff --git a/storage/ctc/ctc_ddl_rewriter_plugin.cc b/storage/ctc/ctc_ddl_rewriter_plugin.cc index 45aa8d3..48f0fe0 100644 --- a/storage/ctc/ctc_ddl_rewriter_plugin.cc +++ b/storage/ctc/ctc_ddl_rewriter_plugin.cc @@ -339,10 +339,10 @@ static int ctc_rewrite_alter_user4update_passwd(MYSQL_THD thd, string &sql_str) while ((tmp_user = user_list++)) { /* If it is an empty lex_user update it with current user */ if (!tmp_user->host.str && !tmp_user->user.str) { - assert(sctx->priv_host().str); + assert_log(sctx->priv_host().str, "priv_host is null"); tmp_user->host.str = sctx->priv_host().str; tmp_user->host.length = strlen(sctx->priv_host().str); - assert(sctx->user().str); + assert_log(sctx->user().str, "user is null"); tmp_user->user.str = sctx->user().str; tmp_user->user.length = strlen(sctx->user().str); } @@ -392,7 +392,8 @@ static int ctc_rewrite_setpasswd(MYSQL_THD thd, string &sql_str) { string user2host(""); List *lex_var_list = &thd->lex->var_list; - assert(lex_var_list->elements == 1); + assert_log(lex_var_list->elements == 1, "Expected exactly one variable in the list, but found %u elements.", + lex_var_list->elements); List_iterator_fast it(*lex_var_list); set_var_base *var; while ((var = it++)) { @@ -1288,8 +1289,10 @@ static int ctc_ddl_rewrite(MYSQL_THD thd, mysql_event_class_t event_class, /* We can exit early if this is not a pre-parse event. */ const struct mysql_event_parse *event_parse = static_cast(event); - assert(event_class == MYSQL_AUDIT_PARSE_CLASS && - event_parse->event_subclass == MYSQL_AUDIT_PARSE_POSTPARSE); + assert_log(event_class == MYSQL_AUDIT_PARSE_CLASS && + event_parse->event_subclass == MYSQL_AUDIT_PARSE_POSTPARSE, + "Event class or subclass mismatch: expected MYSQL_AUDIT_PARSE_CLASS and MYSQL_AUDIT_PARSE_POSTPARSE, event_class %d and subclass %d.", + event_class, event_parse->event_subclass); if (event_class != MYSQL_AUDIT_PARSE_CLASS || event_parse->event_subclass != MYSQL_AUDIT_PARSE_POSTPARSE) { return 1; } diff --git a/storage/ctc/ctc_ddl_util.cc b/storage/ctc/ctc_ddl_util.cc index ef26c46..799047b 100644 --- a/storage/ctc/ctc_ddl_util.cc +++ b/storage/ctc/ctc_ddl_util.cc @@ -24,7 +24,8 @@ const char *ibd_suffix = ".ibd"; void *ctc_ddl_alloc_mem(char **mem_start, char *mem_end, size_t malloc_size) { - assert(mem_start != NULL && *mem_start != NULL && mem_end != NULL); + assert_log(mem_start != NULL && *mem_start != NULL && mem_end != NULL, + "Invalid pointers provided to ctc_ddl_alloc_mem: mem_start is NULL, or mem_start points to NULL, or mem_end is NULL."); if (*mem_start + malloc_size >= mem_end) { ctc_log_error("alloc ddl mem failed,size:%u", (uint32_t)malloc_size); return NULL; @@ -332,8 +333,7 @@ ctc_ddl_fk_rule ctc_ddl_get_foreign_key_rule(fk_option rule) { default: break; } - ctc_log_error("unknown foreign key option %d", (int)rule); - assert(0); + assert_log(0, "unknown foreign key option %d", (int)rule); return CTC_DDL_FK_RULE_UNKNOW; } @@ -350,8 +350,7 @@ ctc_ddl_fk_rule ctc_ddl_get_foreign_key_rule(dd::Foreign_key::enum_rule rule) { default: break; } - ctc_log_error("unknown foreign key option %d", (int)rule); - assert(0); + assert_log(0, "unknown foreign key option %d", (int)rule); return CTC_DDL_FK_RULE_UNKNOW; } @@ -448,7 +447,7 @@ uint16 get_prefix_index_len(const Field *field, const uint16 key_length) { key_length < field->pack_length() - field->get_length_bytes()))) { prefix_len = key_length; prefix_len /= field->charset()->mbmaxlen; - assert(!field->gcol_info); + assert_log(!field->gcol_info, "Attempted to calculate prefix index length for a generated column, which is not supported."); } return prefix_len; } diff --git a/storage/ctc/ctc_log.h b/storage/ctc/ctc_log.h index 144f809..22ff5b4 100644 --- a/storage/ctc/ctc_log.h +++ b/storage/ctc/ctc_log.h @@ -80,6 +80,14 @@ static void do_security_filter(char *filter_str) { */ +#define assert_log(expr, fmt, args...) \ + do { \ + if (!(expr)) { \ + ctc_log_print(ERROR_LEVEL, "[%s:%s(%d)] " fmt, __FILENAME__, __FUNCTION__, __LINE__, ##args); fflush(stdout); \ + assert(expr); \ + } \ + } while (0) + inline void ctc_log_print(enum loglevel loglevel, const char *fmt, ...) MY_ATTRIBUTE((format(printf, 2, 3))); void ctc_log_print(enum loglevel loglevel, const char *fmt, ...) { diff --git a/storage/ctc/ctc_meta_data.cc b/storage/ctc/ctc_meta_data.cc index 5909e3a..c362de8 100644 --- a/storage/ctc/ctc_meta_data.cc +++ b/storage/ctc/ctc_meta_data.cc @@ -123,7 +123,7 @@ static void release_ctc_mdl_thd_by_key(uint64_t mdl_thd_key) { } THD *thd = g_ctc_mdl_thd_map[mdl_thd_key]; - assert(thd); + assert_log(thd, "[CTC_MDL_THD]: THD is null for mdl_thd_key=%lu", mdl_thd_key); bool error = 0; release_routine_and_schema(thd, &error); release_ctc_thd_tickets(thd); @@ -139,7 +139,7 @@ static void release_ctc_mdl_thd_by_cantian_id(uint16_t cantian_inst_id) { for (auto iter = g_ctc_mdl_thd_map.begin(); iter != g_ctc_mdl_thd_map.end(); ) { if (ctc_get_cantian_id_from_conn_key(iter->first) == cantian_inst_id) { THD *thd = iter->second; - assert(thd); + assert_log(thd, "[CTC_MDL_THD]: THD is null for cantian_inst_id:%u", cantian_inst_id); bool error = 0; release_routine_and_schema(thd, &error); release_ctc_thd_tickets(thd); @@ -157,7 +157,7 @@ static void release_ctc_mdl_thd_by_inst_id(uint32_t mysql_inst_id) { for (auto iter = g_ctc_mdl_thd_map.begin(); iter != g_ctc_mdl_thd_map.end(); ) { if (ctc_get_inst_id_from_conn_key(iter->first) == mysql_inst_id) { THD *thd = iter->second; - assert(thd); + assert_log(thd, "[CTC_MDL_THD]: THD is null for mysql_inst_id:%u.", mysql_inst_id); bool error = 0; release_routine_and_schema(thd, &error); release_ctc_thd_tickets(thd); @@ -196,7 +196,7 @@ static void ctc_insert_schema(THD *thd, invalidate_obj_entry_t *obj) { vector *invalidate_schema_list = nullptr; if (it == g_ctc_invalidate_schema_maps.end()) { invalidate_schema_list = new vector; - assert(invalidate_schema_list); + assert_log(invalidate_schema_list, "Failed to allocate memory for invalidate_schema_list."); g_ctc_invalidate_schema_maps[thd] = invalidate_schema_list; } g_ctc_invalidate_schema_maps[thd]->emplace_back(obj); @@ -210,7 +210,7 @@ static void ctc_insert_routine(THD *thd, invalidate_obj_entry_t *obj) { vector *invalidate_routine_list = nullptr; if (it == g_ctc_invalidate_routine_maps.end()) { invalidate_routine_list = new vector; - assert(invalidate_routine_list); + assert_log(invalidate_routine_list, "Failed to allocate memory for invalidate_routine_list."); g_ctc_invalidate_routine_maps[thd] = invalidate_routine_list; } g_ctc_invalidate_routine_maps[thd]->emplace_back(obj); @@ -230,7 +230,7 @@ typename std::enable_if::type MDL_REQUEST_INIT(&mdl_request, MDL_key::SCHEMA, schema_name, "", MDL_INTENTION_EXCLUSIVE, MDL_EXPLICIT); if (thd->mdl_context.acquire_lock(&mdl_request, CTC_MDL_TIMEOUT)) { - assert(thd->killed || thd->is_error()); + assert_log(thd->killed || thd->is_error(), "[invalidate_routine]: failed to acquire MDL_INTENTION_EXCLUSIVE, thd is alive and without error"); return true; } schema_ticket = mdl_request.ticket; @@ -250,7 +250,7 @@ typename std::enable_if::type MDL_request mdl_request; MDL_REQUEST_INIT_BY_KEY(&mdl_request, &mdl_key, MDL_EXCLUSIVE, MDL_EXPLICIT); if (thd->mdl_context.acquire_lock(&mdl_request, CTC_MDL_TIMEOUT)) { - assert(thd->killed || thd->is_error()); + assert_log(thd->killed || thd->is_error(), "[invalidate_routine]: failed to acquire MDL_EXCLUSIVE, thd is alive and without error."); ctc_log_error("[INVALIDATE_ROUTINE]: Failed to acquire routine/procedure mdl of schema_name:%s and routine_name:%s", schema_name, routine_name); return true; } @@ -308,7 +308,7 @@ typename std::enable_if::type MDL_REQUEST_INIT(&mdl_request, MDL_key::SCHEMA, schema_name, "", MDL_INTENTION_EXCLUSIVE, MDL_EXPLICIT); if (thd->mdl_context.acquire_lock(&mdl_request, CTC_MDL_TIMEOUT)) { - assert(thd->killed || thd->is_error()); + assert_log(thd->killed || thd->is_error(), "[invalidate_table]: failed to acquire MDL_INTENTION_EXCLUSIVE, thd is alive and without error."); ctc_log_error("[INVALIDATE_TABLE]: Failed to acquire schema mdl lock of schema:%s and table:%s ", schema_name, table_name); return true; } @@ -321,7 +321,7 @@ typename std::enable_if::type MDL_REQUEST_INIT(&mdl_request, MDL_key::TABLE, schema_name, table_name, MDL_EXCLUSIVE, MDL_EXPLICIT); if (thd->mdl_context.acquire_lock(&mdl_request, CTC_MDL_TIMEOUT)) { - assert(thd->killed || thd->is_error()); + assert_log(thd->killed || thd->is_error(), "[INVALIDATE_TABLE]: failed to acquire MDL_EXCLUSIVE, thd is alive and without error."); ctc_log_error("[INVALIDATE_TABLE]: Failed to acquire table mdl lock of schema:%s and table:%s ", schema_name, table_name); return true; } @@ -359,7 +359,7 @@ typename std::enable_if::type MDL_EXCLUSIVE, MDL_EXPLICIT); if (thd->mdl_context.acquire_lock(&mdl_request, CTC_MDL_TIMEOUT)) { - assert(thd->killed || thd->is_error()); + assert_log(thd->killed || thd->is_error(), "[invalidate_schema]: failed to acquire MDL_EXCLUSIVE, thd is alive and without error."); ctc_log_error("[INVALIDATE_SCHEMA]: Failed to acquire schema(%s) mdl lock .", schema_name); return true; } @@ -397,7 +397,7 @@ typename std::enable_if::type MDL_EXCLUSIVE, MDL_EXPLICIT); if (thd->mdl_context.acquire_lock(&mdl_request, CTC_MDL_TIMEOUT)) { - assert(thd->killed || thd->is_error()); + assert_log(thd->killed || thd->is_error(), "[INVALIDATE_TABLESPACE]: failed to acquire MDL_EXCLUSIVE, thd is alive and without error."); ctc_log_error("[INVALIDATE_TABLESPACE]: Failed to acquire tablespace mdl lock of tablespace_name:%s", tablespace_name); return true; } @@ -451,7 +451,7 @@ static typename std::enable_if::type bool is_end = (buff[0] == '1'); while (offset < buff_len) { obj = (invalidate_obj_entry_t *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(invalidate_obj_entry_t), MYF(MY_WME)); - assert(obj); + assert_log(obj, "Failed to allocate memory for invalidate_obj_entry_t."); memcpy(obj, buff + offset, sizeof(invalidate_obj_entry_t)); printf("\n[ctc_invalidate_mysql_dd_cache_impl] type: %u, first: %s, second: %s\n", obj->type, obj->first, obj->second); fflush(stdout); switch (obj->type) { @@ -631,7 +631,7 @@ int ctc_mdl_lock_thd(ctc_handler_t *tch, ctc_lock_table_info *lock_info, int *er } string mdl_ticket_key; mdl_ticket_key.assign(((const char*)(ctc_mdl_request.key.ptr())), ctc_mdl_request.key.length()); - assert(mdl_ticket_key.length() > 0); + assert_log(mdl_ticket_key.length() > 0, "[ctc_mdl_lock_thd]: MDL ticket key is empty, ctc_mdl_request.key: %s.", ctc_mdl_request.key.ptr()); ctc_mdl_ticket_map->insert(map::value_type(mdl_ticket_key, ctc_mdl_request.ticket)); thd->restore_globals(); @@ -682,7 +682,7 @@ void ctc_mdl_unlock_tables_thd(ctc_handler_t *tch) { return; } THD* thd = iter->second; - assert(thd); + assert_log(thd, "[ctc_mdl_unlock_tables_thd]: THD pointer is null for mdl_thd_key: %lu", mdl_thd_key); my_thread_init(); thd->store_globals(); @@ -733,7 +733,7 @@ void ctc_mdl_unlock_thd(ctc_handler_t *tch, ctc_lock_table_info *lock_info) { return; } THD* thd = iter->second; - assert(thd); + assert_log(thd, "[ctc_mdl_unlock_thd]: THD pointer is null for mdl_thd_key: %lu", mdl_thd_key); my_thread_init(); thd->store_globals(); @@ -975,7 +975,7 @@ int ctc_ddl_execute_lock_tables_by_req(ctc_handler_t *tch, ctc_lock_table_info * } string mdl_ticket_key; mdl_ticket_key.assign(((const char*)(ctc_mdl_request.key.ptr())), ctc_mdl_request.key.length()); - assert(mdl_ticket_key.length() > 0); + assert_log(mdl_ticket_key.length() > 0, "[ctc_ddl_execute_lock]: MDL ticket key is empty, ctc_mdl_request.key: %s.", ctc_mdl_request.key.ptr()); ctc_mdl_ticket_map->insert(map::value_type(mdl_ticket_key, ctc_mdl_request.ticket)); thd->restore_globals(); diff --git a/storage/ctc/ctc_mysql_proxy.cc b/storage/ctc/ctc_mysql_proxy.cc index 8141c5f..57d4254 100644 --- a/storage/ctc/ctc_mysql_proxy.cc +++ b/storage/ctc/ctc_mysql_proxy.cc @@ -105,9 +105,8 @@ static void ctc_drop_proxy_user(MYSQL *agent_conn, const string &proxy_user_name string drop_user_sql = "drop user if exists '" + proxy_user_name + "';"; if (ctc_mysql_query(agent_conn, drop_user_sql.c_str())) { - ctc_log_error("ctc_drop_proxy_user failed, drop user=%s, sql=%s, err_code=%d, err_msg=%s", + assert_log(0, "ctc_drop_proxy_user failed, drop user=%s, sql=%s, err_code=%d, err_msg=%s", proxy_user_name.c_str(), drop_user_sql.c_str(), mysql_errno(agent_conn), mysql_error(agent_conn)); - assert(0); } } @@ -232,7 +231,7 @@ int ctc_init_mysql_client(uint64_t conn_map_key, const char *db, MYSQL *&curr_co ctc_close_mysql_conn(&curr_conn); } - assert(curr_conn == nullptr); + assert_log(curr_conn == nullptr, "after closing mysql connection, curr_conn is not null."); while(!mysqld_server_started) { ctc_log_system("[CTC_INIT]:ctc_init_mysql_client wait mysql server start!!!!"); sleep(1); diff --git a/storage/ctc/ctc_srv_mq_module.cc b/storage/ctc/ctc_srv_mq_module.cc index 80a0706..101bf11 100644 --- a/storage/ctc/ctc_srv_mq_module.cc +++ b/storage/ctc/ctc_srv_mq_module.cc @@ -132,8 +132,7 @@ int mq_recv_msg(struct shm_seg_s *shm_seg, dsw_message_block_t *message_block) int result; pthread_t thd; if (g_ddl_thd_num > MAX_DDL_THD_NUM) { - ctc_log_error("ddl thd has reach max limit: %d", MAX_DDL_THD_NUM); - assert(0); + assert_log(0, "ddl thd has reach max limit: %d", MAX_DDL_THD_NUM); } result = pthread_create(&thd, NULL, mq_msg_handler, (void*)message_block); if (result != 0) { @@ -476,7 +475,7 @@ int ctc_mq_get_batch_data(dsw_message_block_t *message_block, uint8_t *buf_data, static int ctc_mq_fill_batch_data(shm_seg_s *seg, dsw_message_block_t* msg, uint8_t* data_buf, uint32_t data_len, uint32_t buf_size) { - assert(data_len <= buf_size); + assert_log(data_len <= buf_size, ""); uint8_t* buf_tmp = data_buf; msg->head.seg_num = 0; diff --git a/storage/ctc/ctc_srv_mq_stub.cc b/storage/ctc/ctc_srv_mq_stub.cc index 4d56307..dec5348 100644 --- a/storage/ctc/ctc_srv_mq_stub.cc +++ b/storage/ctc/ctc_srv_mq_stub.cc @@ -150,7 +150,8 @@ int ctc_write_row(ctc_handler_t *tch, const record_info_t *record_info, int ctc_bulk_write(ctc_handler_t *tch, const record_info_t *record_info, uint64_t rec_num, uint32_t *err_pos, dml_flag_t flag, ctc_part_t *part_ids) { void *shm_inst = get_one_shm_inst(tch); - assert(record_info->record_len * rec_num <= MAX_RECORD_SIZE); + assert_log(record_info->record_len * rec_num <= MAX_RECORD_SIZE, + "Total record size exceeds the maximum allowed size. record_len: %u, rec_num: %lu", record_info->record_len, rec_num); bulk_write_request *req = (bulk_write_request*)alloc_share_mem(shm_inst, sizeof(bulk_write_request)); if (req == NULL) { ctc_log_error("alloc shm mem error, shm_inst(%p), size(%lu)", shm_inst, sizeof(bulk_write_request)); @@ -180,8 +181,8 @@ int ctc_bulk_write(ctc_handler_t *tch, const record_info_t *record_info, uint64_ int ctc_update_row(ctc_handler_t *tch, uint16_t new_record_len, const uint8_t *new_record, const uint16_t *upd_cols, uint16_t col_num, dml_flag_t flag) { - assert(new_record_len < BIG_RECORD_SIZE); - assert(col_num <= CTC_MAX_COLUMNS); + assert_log(new_record_len < BIG_RECORD_SIZE, "[ctc_update_row]: new_record_len: %u exceeds BIG_RECORD_SIZE", new_record_len); + assert_log(col_num <= CTC_MAX_COLUMNS, "[ctc_update_row]: col_num: %u exceeds CTC_MAX_COLUMNS", col_num); void *shm_inst = get_one_shm_inst(tch); update_row_request *req = (update_row_request*)alloc_share_mem(shm_inst, sizeof(update_row_request)); if (req == NULL) { @@ -205,7 +206,7 @@ int ctc_update_row(ctc_handler_t *tch, uint16_t new_record_len, const uint8_t *n } int ctc_delete_row(ctc_handler_t *tch, uint16_t record_len, dml_flag_t flag) { - assert(record_len < BIG_RECORD_SIZE); + assert_log(record_len < BIG_RECORD_SIZE); void *shm_inst = get_one_shm_inst(tch); delete_row_request *req = (delete_row_request*)alloc_share_mem(shm_inst, sizeof(delete_row_request)); if (req == NULL) { @@ -267,7 +268,7 @@ int ctc_rnd_next(ctc_handler_t *tch, record_info_t *record_info) { if (ret == CT_SUCCESS) { if(req->result == CT_SUCCESS) { record_info->record_len = req->record_len; - assert(record_info->record_len < BIG_RECORD_SIZE); + assert_log(record_info->record_len < BIG_RECORD_SIZE, "[ctc_rnd_next]: record_info->record_len: %u exceeds BIG_RECORD_SIZE", record_info->record_len); } result = req->result; } @@ -352,7 +353,7 @@ int ctc_rnd_end(ctc_handler_t *tch) { } int ctc_position(ctc_handler_t *tch, uint8_t *position, uint16_t pos_length) { - assert(pos_length < SMALL_RECORD_SIZE); + assert_log(pos_length < SMALL_RECORD_SIZE, "[ctc_position]: pos_length: %u exceeds SMALL_RECORD_SIZE", pos_length); void *shm_inst = get_one_shm_inst(tch); position_request *req = (position_request*)alloc_share_mem(shm_inst, sizeof(position_request)); if (req == NULL) { @@ -374,7 +375,7 @@ int ctc_position(ctc_handler_t *tch, uint8_t *position, uint16_t pos_length) { } int ctc_rnd_pos(ctc_handler_t *tch, uint16_t pos_length, uint8_t *position, record_info_t *record_info) { - assert(pos_length < SMALL_RECORD_SIZE); + assert_log(pos_length < SMALL_RECORD_SIZE, "[ctc_rnd_pos]: pos_length: %u exceeds SMALL_RECORD_SIZE", pos_length); void *shm_inst = get_one_shm_inst(tch); rnd_pos_request *req = (rnd_pos_request*)alloc_share_mem(shm_inst, sizeof(rnd_pos_request)); if (req == NULL) { @@ -392,7 +393,7 @@ int ctc_rnd_pos(ctc_handler_t *tch, uint16_t pos_length, uint8_t *position, reco if (ret == CT_SUCCESS) { if(req->result == CT_SUCCESS) { record_info->record_len = req->record_len; - assert(record_info->record_len < BIG_RECORD_SIZE); + assert_log(record_info->record_len < BIG_RECORD_SIZE, "[ctc_rnd_pos]: record_len: %u exceeds BIG_RECORD_SIZE", record_info->record_len); } result = req->result; } @@ -450,7 +451,9 @@ static void copy_index_info_to_req(const index_key_info_t *index_info, index_rea for (int i = 0; i < index_info->key_num; ++i) { req->is_key_null[i] = index_info->key_info[i].is_key_null; if (index_info->key_info[i].left_key != nullptr) { - assert(left_offset + index_info->key_info[i].left_key_len <= INDEX_KEY_SIZE); + assert_log(left_offset + index_info->key_info[i].left_key_len <= INDEX_KEY_SIZE, + "[copy_index_info]: Left key data exceeds the maximum index key size. Offset: %u, Key length: %u", + left_offset, index_info->key_info[i].left_key_len); memcpy(pLeft, index_info->key_info[i].left_key, index_info->key_info[i].left_key_len); pLeft += index_info->key_info[i].left_key_len; req->left_key_info.key_offsets[i] = left_offset; @@ -462,7 +465,9 @@ static void copy_index_info_to_req(const index_key_info_t *index_info, index_rea } if (index_info->key_info[i].right_key != nullptr) { - assert(right_offset + index_info->key_info[i].right_key_len <= INDEX_KEY_SIZE); + assert_log(right_offset + index_info->key_info[i].right_key_len <= INDEX_KEY_SIZE, + "[copy_index_info]: Right key data exceeds the maximum index key size. Offset: %u, Key length: %u", + right_offset, index_info->key_info[i].right_key_len); memcpy(pRight, index_info->key_info[i].right_key, index_info->key_info[i].right_key_len); pRight += index_info->key_info[i].right_key_len; req->right_key_info.key_offsets[i] = right_offset; @@ -515,7 +520,7 @@ int ctc_index_read(ctc_handler_t *tch, record_info_t *record_info, index_key_inf if (ret == CT_SUCCESS) { if(req->result == CT_SUCCESS) { record_info->record_len = req->record_len; - assert(record_info->record_len < BIG_RECORD_SIZE); + assert_log(record_info->record_len < BIG_RECORD_SIZE, "[ctc_index_read]: record_info->record_len: %u exceeds BIG_RECORD_SIZE", record_info->record_len); } result = req->result; index_info->need_init = req->need_init; @@ -665,7 +670,7 @@ int ctc_general_fetch(ctc_handler_t *tch, record_info_t *record_info) { if (ret == CT_SUCCESS) { if (req->result == CT_SUCCESS) { record_info->record_len = req->record_len; - assert(record_info->record_len < BIG_RECORD_SIZE); + assert_log(record_info->record_len < BIG_RECORD_SIZE, "[ctc_general_fetch]: record_info->record_len: %u exceeds BIG_RECORD_SIZE", record_info->record_len); } result = req->result; } @@ -1213,7 +1218,7 @@ int ctc_knl_read_lob(ctc_handler_t *tch, char* locator, uint32_t offset, void *b } else { if(req->result == CT_SUCCESS) { *read_size = (uint32_t)(req->read_size); - assert(*read_size <= size); + assert_log(*read_size <= size, "[ctc_knl_read_lob]: read_size: %u exceeds size: %u .", *read_size, size); memcpy(buf, req->buf, *read_size); } result = req->result; @@ -1248,7 +1253,9 @@ int ctc_create_table(void *table_def, ddl_ctrl_t *ddl_ctrl) { } int ctc_truncate_table(void *table_def, ddl_ctrl_t *ddl_ctrl) { - assert(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE); + assert_log(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE, + "[ctc_truncate_table]: ddl_ctrl size exceeds the maximum request size. msg_len: %u, sizeof(ddl_ctrl_t): %u, REQUEST_SIZE: %u", + ddl_ctrl->msg_len, sizeof(ddl_ctrl_t), REQUEST_SIZE); void *shm_inst = get_one_shm_inst(NULL); void *req_mem = alloc_share_mem(shm_inst, ddl_ctrl->msg_len + sizeof(ddl_ctrl_t)); DBUG_EXECUTE_IF("truncate_table_shm_oom", { req_mem = NULL; }); @@ -1293,7 +1300,9 @@ int ctc_alter_table(void *alter_def, ddl_ctrl_t *ddl_ctrl) { } int ctc_rename_table(void *alter_def, ddl_ctrl_t *ddl_ctrl) { - assert(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE); + assert_log(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE, + "[ctc_rename_table]: ddl_ctrl size exceeds the maximum request size. msg_len: %u, sizeof(ddl_ctrl_t): %u, REQUEST_SIZE: %u", + ddl_ctrl->msg_len, sizeof(ddl_ctrl_t), REQUEST_SIZE); void *shm_inst = get_one_shm_inst(NULL); void *req_mem = alloc_share_mem(shm_inst, ddl_ctrl->msg_len + sizeof(ddl_ctrl_t)); DBUG_EXECUTE_IF("rename_table_shm_oom", { req_mem = NULL; }); @@ -1423,7 +1432,9 @@ int ctc_get_serial_value(ctc_handler_t *tch, uint64_t *value, dml_flag_t flag) { } int ctc_drop_table(void *drop_def, ddl_ctrl_t *ddl_ctrl) { - assert(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE); + assert_log(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE, + "[ctc_rename_table]: ddl_ctrl size exceeds the maximum request size. msg_len: %u, sizeof(ddl_ctrl_t): %u, REQUEST_SIZE: %u", + ddl_ctrl->msg_len, sizeof(ddl_ctrl_t), REQUEST_SIZE); void *shm_inst = get_one_shm_inst(NULL); void *req_mem = alloc_share_mem(shm_inst, ddl_ctrl->msg_len + sizeof(ddl_ctrl_t)); DBUG_EXECUTE_IF("drop_table_shm_oom", { req_mem = NULL; }); @@ -1444,7 +1455,9 @@ int ctc_drop_table(void *drop_def, ddl_ctrl_t *ddl_ctrl) { } int ctc_create_tablespace(void *space_def, ddl_ctrl_t *ddl_ctrl) { - assert(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE); + assert_log(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE, + "[ctc_create_tablespace]: ddl_ctrl size exceeds the maximum request size. msg_len: %u, sizeof(ddl_ctrl_t): %u, REQUEST_SIZE: %u", + ddl_ctrl->msg_len, sizeof(ddl_ctrl_t), REQUEST_SIZE); void *shm_inst = get_one_shm_inst(NULL); void *req_mem = alloc_share_mem(shm_inst, ddl_ctrl->msg_len + sizeof(ddl_ctrl_t)); DBUG_EXECUTE_IF("create_tablespace_shm_oom", { req_mem = NULL; }); @@ -1465,7 +1478,9 @@ int ctc_create_tablespace(void *space_def, ddl_ctrl_t *ddl_ctrl) { } int ctc_alter_tablespace(void *space_alter_def, ddl_ctrl_t *ddl_ctrl) { - assert(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE); + assert_log(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE, + "[ctc_alter_tablespace]: ddl_ctrl size exceeds the maximum request size. msg_len: %u, sizeof(ddl_ctrl_t): %u, REQUEST_SIZE: %u", + ddl_ctrl->msg_len, sizeof(ddl_ctrl_t), REQUEST_SIZE); void *shm_inst = get_one_shm_inst(NULL); void *req_mem = alloc_share_mem(shm_inst, ddl_ctrl->msg_len + sizeof(ddl_ctrl_t)); DBUG_EXECUTE_IF("alter_tablespace_shm_oom", { req_mem = NULL; }); @@ -1486,7 +1501,9 @@ int ctc_alter_tablespace(void *space_alter_def, ddl_ctrl_t *ddl_ctrl) { } int ctc_drop_tablespace(void *space_drop_def, ddl_ctrl_t *ddl_ctrl) { - assert(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE); + assert_log(ddl_ctrl->msg_len + sizeof(ddl_ctrl_t) < REQUEST_SIZE, + "[ctc_drop_tablespace]: ddl_ctrl size exceeds the maximum request size. msg_len: %u, sizeof(ddl_ctrl_t): %u, REQUEST_SIZE: %u", + ddl_ctrl->msg_len, sizeof(ddl_ctrl_t), REQUEST_SIZE); void *shm_inst = get_one_shm_inst(NULL); void *req_mem = alloc_share_mem(shm_inst, ddl_ctrl->msg_len + sizeof(ddl_ctrl_t)); DBUG_EXECUTE_IF("drop_tablespace_shm_oom", { req_mem = NULL; }); diff --git a/storage/ctc/ctc_util.cc b/storage/ctc/ctc_util.cc index 6cde6e5..e830fc6 100644 --- a/storage/ctc/ctc_util.cc +++ b/storage/ctc/ctc_util.cc @@ -224,8 +224,7 @@ int ctc_fill_cond_field_data_num(ctc_handler_t m_tch, Item *items, Field *mysql_ break; } default: - ctc_log_error("[ctc_copy_cond_field_data]unsupport sql_data_type %d", mysql_info->sql_data_type); - assert(0); + assert_log(0, "[ctc_copy_cond_field_data]unsupport sql_data_type %d", mysql_info->sql_data_type); return CT_ERROR; } uchar cantian_ptr[DECIMAL_MAX_STR_LENGTH + 1]; diff --git a/storage/ctc/datatype_cnvrtr.cc b/storage/ctc/datatype_cnvrtr.cc index 7ad5c9e..4dd0f21 100644 --- a/storage/ctc/datatype_cnvrtr.cc +++ b/storage/ctc/datatype_cnvrtr.cc @@ -386,8 +386,7 @@ int decimal_mysql_to_cantian(const uint8_t *mysql_ptr, uchar *cantian_ptr, Field } dec8_t d8; if (ct_cm_str_to_dec8(buff, &d8) != CT_SUCCESS_STATUS) { - ctc_log_error("[mysql2cantian]Decimal data type convert str to dec8 failed!"); - assert(0); + assert_log(0, "[mysql2cantian]Decimal data type convert str to dec8 failed!"); } cm_dec_8_to_4((dec4_t *)cantian_ptr, &d8); *length = (uint32)cm_dec4_stor_sz((dec4_t *)cantian_ptr); diff --git a/storage/ctc/ha_ctc.cc b/storage/ctc/ha_ctc.cc index 6032249..cee1b8a 100644 --- a/storage/ctc/ha_ctc.cc +++ b/storage/ctc/ha_ctc.cc @@ -707,7 +707,7 @@ int create_and_conditions(Item_cond *cond, List pushed_list, int create_or_conditions(Item_cond *cond, List pushed_list, List remainder_list, Item *&pushed_cond, Item *&remainder_cond) { - assert(pushed_list.elements == cond->argument_list()->elements); + assert_log(pushed_list.elements == cond->argument_list()->elements); if (remainder_list.is_empty()) { // Entire cond pushed, no remainder @@ -3942,8 +3942,7 @@ enum_alter_inplace_result ha_ctc::check_if_supported_inplace_alter( for (int i = add_column_size; i > 0; i--) { int32_t add_column_idx = create_list_size - i; if (add_column_idx < 0) { - assert(0); - ctc_log_error("[SUPPORT_INPLACE]: add_column_idx smaller than 0."); + assert_log(0, "[SUPPORT_INPLACE]: add_column_idx smaller than 0."); break; } -- Gitee