/*******************************************************// 如果找到,则从索引中删除二级索引条目。首先尝试乐观下降,然后是悲观下降树。 @return DB_SUCCESS或DB_OUT_OF_FILE_SPACE/ static ulint row_undo_ins_remove_sec( /====================/ dict_index_t index, /!< in: 索引 / dtuple_t entry) /!< in: 要插入的索引条目 */ { ulint err; ulint n_tries = 0;

/* 首先尝试乐观下降到B树 */

err = row_undo_ins_remove_sec_low(BTR_MODIFY_LEAF, index, entry);

if (err == DB_SUCCESS) {

	return(err);
}

/* 然后尝试悲观下降到B树 */

retry: err = row_undo_ins_remove_sec_low(BTR_MODIFY_TREE, index, entry);

/* 如果我们剩余的文件空间很少,则删除操作可能会失败:TODO:最简单的方法是崩溃数据库并重新启动更多的文件空间*/

if (err != DB_SUCCESS && n_tries < BTR_CUR_RETRY_DELETE_N_TIMES) {

	n_tries++;

	os_thread_sleep(BTR_CUR_RETRY_SLEEP_TIME);

	goto retry;
}

return(err);

}

/*********************************************************// 解析新插入撤消记录中的行引用和其他信息。/ static void row_undo_ins_parse_undo_rec( /========================/ undo_node_t node) /!< in/out: 行撤消节点 / { dict_index_t clust_index; byte ptr; undo_no_t undo_no; table_id_t table_id; ulint type; ulint dummy; ibool dummy_extern;

ut_ad(node);

ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &dummy,
			    &dummy_extern, &undo_no, &table_id);
ut_ad(type == TRX_UNDO_INSERT_REC);
node->rec_type = type;

node->update = NULL;
node->table = dict_table_get_on_id(table_id, node->trx);

/* 如果找不到表或.ibd文件,则跳过UNDO。*/
if (UNIV_UNLIKELY(node->table == NULL)) {
} else if (UNIV_UNLIKELY(node->table->ibd_file_missing)) {
	node->table = NULL;
} else {
	clust_index = dict_table_get_first_index(node->table);

	if (clust_index != NULL) {
		ptr = trx_undo_rec_get_row_ref(
			ptr, clust_index, &node->ref, node->heap);
	} else {
		ut_print_timestamp(stderr);
		fprintf(stderr, "  InnoDB: 表 ");
		ut_print_name(stderr, node->trx, TRUE,
			      node->table->name);
		fprintf(stderr, "没有索引,忽略该表\n");

		node->table = NULL;
	}
}
Removes a secondary index entry from the index if found Tries firstoptimistic then pessimistic descent down the treereturn	DB_SUCCESS or DB_OUT_OF_FILE_SPACE staticulintrow_undo_ins_remove_sec========

原文地址: https://www.cveoy.top/t/topic/fsXL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录