Change legitimacy error code for functional index
This commit is contained in:
		| @ -3603,6 +3603,7 @@ int ObLSTabletService::check_old_row_legitimacy( | ||||
|     ObDatumRowkey datum_rowkey; | ||||
|     ObDatumRowkeyHelper rowkey_helper; | ||||
|     const ObIArray<uint64_t> &column_ids = *run_ctx.column_ids_; | ||||
|     uint64_t err_col_id = OB_INVALID_ID; | ||||
|     if (OB_FAIL(rowkey_helper.convert_datum_rowkey(rowkey.get_rowkey(), datum_rowkey))) { | ||||
|       STORAGE_LOG(WARN, "Failed to transfer datum rowkey", K(ret), K(rowkey)); | ||||
|     } else if (OB_FAIL(init_single_row_getter(old_row_getter, run_ctx, column_ids, data_table, true))) { | ||||
| @ -3636,6 +3637,7 @@ int ObLSTabletService::check_old_row_legitimacy( | ||||
|           if (OB_FAIL(data_table.is_nop_default_value(column_ids.at(i), is_nop))) { | ||||
|             LOG_WARN("check column whether has nop default value failed", K(ret), K(column_ids.at(i))); | ||||
|           } else if (!is_nop) { | ||||
|             err_col_id = column_ids.at(i); | ||||
|             ret = OB_ERR_DEFENSIVE_CHECK; | ||||
|             LOG_WARN("storage old row is not matched with sql old row", K(ret), | ||||
|                     K(i), K(column_ids.at(i)), K(storage_val), K(sql_val)); | ||||
| @ -3644,6 +3646,7 @@ int ObLSTabletService::check_old_row_legitimacy( | ||||
|           //this column is nop val, means that this column does not be touched by DML | ||||
|           //just ignore it | ||||
|         } else if (OB_FAIL(storage_val.compare(sql_val, cmp)) || 0 != cmp) { | ||||
|           err_col_id = column_ids.at(i); | ||||
|           LOG_WARN("storage_val is not equal with sql_val, maybe catch a bug", K(ret), | ||||
|                   K(storage_val), K(sql_val), K(cmp), K(column_ids.at(i))); | ||||
|           ret = OB_ERR_DEFENSIVE_CHECK; | ||||
| @ -3663,6 +3666,7 @@ int ObLSTabletService::check_old_row_legitimacy( | ||||
|     } | ||||
|     if (OB_ERR_DEFENSIVE_CHECK == ret) { | ||||
|       int tmp_ret = OB_SUCCESS; | ||||
|       bool is_virtual_gen_col = false; | ||||
|       if (OB_TMP_FAIL(check_real_leader_for_4377_(run_ctx.store_ctx_.ls_id_))) { | ||||
|         ret = tmp_ret; | ||||
|         LOG_WARN("check real leader for 4377 found exception", K(ret), K(old_row), K(data_table)); | ||||
| @ -3673,7 +3677,14 @@ int ObLSTabletService::check_old_row_legitimacy( | ||||
|       } else if (is_udf) { | ||||
|         ret = OB_ERR_INDEX_KEY_NOT_FOUND; | ||||
|         LOG_WARN("index key not found on udf column", K(ret), K(old_row)); | ||||
|       } else { | ||||
|       } else if (data_table.is_index_table() && OB_TMP_FAIL(check_is_gencol_check_failed(data_table, err_col_id, is_virtual_gen_col))) { | ||||
|         //don't change ret if gencol check failed | ||||
|         LOG_WARN("check is functional index failed", K(ret), K(tmp_ret), K(data_table)); | ||||
|       } else if (is_virtual_gen_col) { | ||||
|         ret = OB_ERR_GENCOL_LEGIT_CHECK_FAILED; | ||||
|         LOG_WARN("Legitimacy check failed for functional index.", K(ret), K(old_row), KPC(storage_old_row)); | ||||
|       } | ||||
|       if (OB_ERR_DEFENSIVE_CHECK == ret) { | ||||
|         ObString func_name = ObString::make_string("check_old_row_legitimacy"); | ||||
|         LOG_USER_ERROR(OB_ERR_DEFENSIVE_CHECK, func_name.length(), func_name.ptr()); | ||||
|         LOG_DBA_ERROR(OB_ERR_DEFENSIVE_CHECK, "msg", "Fatal Error!!! Catch a defensive error!", K(ret), | ||||
| @ -3692,6 +3703,67 @@ int ObLSTabletService::check_old_row_legitimacy( | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| int ObLSTabletService::check_is_gencol_check_failed(const ObRelativeTable &data_table, uint64_t error_col_id, bool &is_virtual_gen_col) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   is_virtual_gen_col = false; | ||||
|   if (data_table.is_index_table()) { | ||||
|     const ObColumnParam *param = nullptr; | ||||
|     const uint64_t tenant_id = MTL_ID(); | ||||
|     uint64_t index_table_id = data_table.get_table_id(); | ||||
|     const ObTableSchema *index_table_schema = NULL; | ||||
|     const ObTableSchema *data_table_schema = NULL; | ||||
|     ObMultiVersionSchemaService *schema_service = MTL(ObTenantSchemaService*)->get_schema_service(); | ||||
|     ObSchemaGetterGuard schema_guard; | ||||
|     if (OB_ISNULL(schema_service)) { | ||||
|       ret = OB_ERR_UNEXPECTED; | ||||
|       LOG_WARN("unexpected null", K(ret), KP(schema_service)); | ||||
|     } else if (OB_FAIL(schema_service->get_tenant_schema_guard(tenant_id, schema_guard))) { | ||||
|       LOG_WARN("failed to get schema manager", K(ret), K(tenant_id)); | ||||
|     }  else if (OB_FAIL(schema_guard.get_table_schema(tenant_id, index_table_id, index_table_schema))) { | ||||
|       LOG_WARN("get index table schema failed", K(ret)); | ||||
|     } else if (OB_ISNULL(index_table_schema)) { | ||||
|       ret = OB_ERR_UNEXPECTED; | ||||
|       LOG_WARN("index table schema is unexpected null", K(ret)); | ||||
|     } else if (OB_FAIL(schema_guard.get_table_schema(tenant_id, index_table_schema->get_data_table_id(), data_table_schema))) { | ||||
|       LOG_WARN("get data table schema failed", K(ret)); | ||||
|     } else if (OB_ISNULL(data_table_schema)) { | ||||
|       ret = OB_ERR_UNEXPECTED; | ||||
|       LOG_WARN("data table schema is unexpected null", K(ret)); | ||||
|     } else if (OB_INVALID_ID != error_col_id) { | ||||
|       //check specified column | ||||
|       const ObColumnSchemaV2 *column = NULL; | ||||
|       if (is_shadow_column(error_col_id)) { | ||||
|         //shadow column does not exists in basic table, do nothing | ||||
|       } else if (OB_ISNULL(column = data_table_schema->get_column_schema(error_col_id))) { | ||||
|         ret = OB_ERR_UNEXPECTED; | ||||
|         LOG_WARN("unexpected null", K(ret), KP(column)); | ||||
|       } else if (column->is_virtual_generated_column()) { | ||||
|         is_virtual_gen_col = true; | ||||
|       } | ||||
|     } else { | ||||
|       //check all columns | ||||
|       for (ObTableSchema::const_column_iterator iter = index_table_schema->column_begin(); | ||||
|           OB_SUCC(ret) && iter != index_table_schema->column_end() && !is_virtual_gen_col; iter++) { | ||||
|         const ObColumnSchemaV2 *column = *iter; | ||||
|         //the column id in the data table is the same with that in the index table | ||||
|         if (OB_ISNULL(column)) { | ||||
|           ret = OB_ERR_UNEXPECTED; | ||||
|           LOG_WARN("unexpected null", K(ret), KP(column)); | ||||
|         } else if (is_shadow_column(column->get_column_id())) { | ||||
|           //shadow column does not exists in basic table, do nothing | ||||
|         } else if (OB_ISNULL(column = data_table_schema->get_column_schema(column->get_column_id()))) { | ||||
|           ret = OB_ERR_UNEXPECTED; | ||||
|           LOG_WARN("unexpected null", K(ret), KP(column)); | ||||
|         } else if (column->is_virtual_generated_column()) { | ||||
|           is_virtual_gen_col = true; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| int ObLSTabletService::check_new_row_legitimacy( | ||||
|     ObDMLRunningCtx &run_ctx, | ||||
|     const common::ObNewRow &new_row) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 2149
					2149