提交 b4bfa011 编写于 作者: O obdev 提交者: wangzelin.wzl

[CP] [CP] fix bug that a tranction span tenant

上级 20910756
......@@ -1216,6 +1216,12 @@ int ObGlobalIndexBuilder::hold_snapshot(const ObGlobalIndexTask* task, const int
LOG_WARN("fail to start trans", K(ret));
} else if (OB_FAIL(ddl_service_->get_snapshot_mgr().acquire_snapshot(trans, info1))) {
LOG_WARN("fail to acquire snapshot", K(ret));
} else if (!info2.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(info2));
} else if (OB_FAIL(ddl_service_->get_snapshot_mgr().set_index_building_snapshot(
proxy, info2.table_id_, info2.snapshot_ts_))) {
LOG_WARN("fail to set index building snapshot", KR(ret), K(info2));
} else if (OB_FAIL(ddl_service_->get_snapshot_mgr().acquire_snapshot_for_building_index(
trans, info2, info2.table_id_))) {
LOG_WARN("fail to acquire snapshot", K(ret));
......
......@@ -931,9 +931,13 @@ int ObRSBuildIndexTask::acquire_snapshot(const int64_t snapshot_version, const i
info.schema_version_ = schema_version;
info.tenant_id_ = extract_tenant_id(index_id_);
info.table_id_ = data_table_id;
common::ObMySQLProxy &proxy = ddl_service_->get_sql_proxy();
if (!info.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(info));
} else if (OB_FAIL(ddl_service_->get_snapshot_mgr().set_index_building_snapshot(
proxy, info.table_id_, info.snapshot_ts_))) {
LOG_WARN("fail to set index building snapshot", KR(ret), K(info));
} else if (OB_FAIL(ddl_service_->get_snapshot_mgr().acquire_snapshot_for_building_index(trans, info, index_id_))) {
LOG_WARN("fail to acquire snapshot", K(ret), K(index_id_), K(data_table_id), K(info));
}
......
......@@ -34,7 +34,7 @@ int ObSnapshotInfoManager::init(const ObAddr& self_addr)
}
int ObSnapshotInfoManager::set_index_building_snapshot(
common::ObMySQLTransaction& trans, const int64_t index_table_id, const int64_t snapshot_ts)
common::ObMySQLProxy &proxy, const int64_t index_table_id, const int64_t snapshot_ts)
{
int ret = OB_SUCCESS;
ObSqlString sql;
......@@ -49,7 +49,7 @@ int ObSnapshotInfoManager::set_index_building_snapshot(
ObSchemaUtils::get_extract_schema_id(tenant_id, index_table_id),
ObSchemaUtils::get_extract_tenant_id(tenant_id, tenant_id)))) {
LOG_WARN("fail to update index building snapshot", KR(ret), K(index_table_id), K(snapshot_ts));
} else if (OB_FAIL(trans.write(tenant_id, sql.ptr(), affected_rows))) {
} else if (OB_FAIL(proxy.write(tenant_id, sql.ptr(), affected_rows))) {
LOG_WARN("fail to write sql", KR(ret), K(sql));
} else if (1 != affected_rows && 0 != affected_rows) {
ret = OB_ERR_UNEXPECTED;
......@@ -66,8 +66,6 @@ int ObSnapshotInfoManager::acquire_snapshot_for_building_index(
if (!snapshot.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(snapshot));
} else if (OB_FAIL(set_index_building_snapshot(trans, index_table_id, snapshot.snapshot_ts_))) {
LOG_WARN("fail to set index building snapshot", KR(ret), K(snapshot));
} else if (OB_FAIL(snapshot_proxy.add_snapshot(trans, snapshot))) {
LOG_WARN("fail to add snapshot", K(ret));
}
......
......@@ -39,12 +39,10 @@ public:
int check_restore_point(common::ObMySQLProxy& proxy, const int64_t tenant_id, const int64_t table_id, bool& is_exist);
int get_snapshot_count(
common::ObMySQLProxy& proxy, const int64_t tenant_id, share::ObSnapShotType snapshot_type, int64_t& count);
common::ObMySQLProxy &proxy, const int64_t tenant_id, share::ObSnapShotType snapshot_type, int64_t &count);
int set_index_building_snapshot(common::ObMySQLProxy &proxy, const int64_t index_table_id, const int64_t snapshot_ts);
private:
int set_index_building_snapshot(
common::ObMySQLTransaction& trans, const int64_t index_table_id, const int64_t snapshot_ts);
DISALLOW_COPY_AND_ASSIGN(ObSnapshotInfoManager);
private:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册