diff --git a/src/share/ob_snapshot_table_proxy.cpp b/src/share/ob_snapshot_table_proxy.cpp index aa8f595f742b5cf5f56a742ed3c7ac08dea359ab..14a8d2af7f2c01c874c4b7668edceeefb6107d8b 100644 --- a/src/share/ob_snapshot_table_proxy.cpp +++ b/src/share/ob_snapshot_table_proxy.cpp @@ -175,6 +175,7 @@ int ObSnapshotTableProxy::batch_add_snapshot( ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid arguments", K(ret), K(tenant_id), K(schema_version), K(snapshot_version), K(tablet_id_array)); } else { + int64_t snapshot_gc_scn = 0; int64_t report_idx = 0; const int64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id); ObSnapshotInfo info; @@ -184,6 +185,9 @@ int ObSnapshotTableProxy::batch_add_snapshot( info.snapshot_ts_ = snapshot_version; info.schema_version_ = schema_version; info.comment_ = comment; + if (OB_FAIL(ObGlobalStatProxy::select_snapshot_gc_scn_for_update(trans, tenant_id, snapshot_gc_scn))) { + LOG_WARN("fail to select gc timstamp for update", KR(ret), K(info), K(tenant_id)); + } while (OB_SUCC(ret) && report_idx < tablet_id_array.count()) { sql.reuse(); columns.reuse(); @@ -192,7 +196,7 @@ int ObSnapshotTableProxy::batch_add_snapshot( for (int64_t i = 0; OB_SUCC(ret) && i < cur_batch_cnt; ++i) { info.tablet_id_ = tablet_id_array.at(report_idx + i).id(); dml.reuse(); - if (OB_FAIL(check_snapshot_valid(trans, info.tenant_id_, info, is_valid))) { + if (OB_FAIL(check_snapshot_valid(snapshot_gc_scn, info, is_valid))) { LOG_WARN("fail to check snapshot valid", KR(ret), K(info), K(tenant_id)); } else if (!is_valid) { ret = OB_SNAPSHOT_DISCARDED; @@ -399,19 +403,15 @@ int ObSnapshotTableProxy::get_all_snapshots( } int ObSnapshotTableProxy::check_snapshot_valid( - ObISQLClient &client, - const uint64_t tenant_id, + const int64_t snapshot_gc_scn, const ObSnapshotInfo &info, - bool &is_valid) + bool &is_valid) const { int ret = OB_SUCCESS; - int64_t snapshot_gc_scn = 0; is_valid = false; if (!info.is_valid()) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", KR(ret), K(info)); - } else if (OB_FAIL(ObGlobalStatProxy::select_snapshot_gc_scn_for_update(client, tenant_id, snapshot_gc_scn))) { - LOG_WARN("fail to select gc timstamp for update", KR(ret), K(info), K(tenant_id)); } else if (info.snapshot_ts_ <= snapshot_gc_scn) { is_valid = false; LOG_WARN("invalid snapshot info", KR(ret), K(info), K(snapshot_gc_scn)); diff --git a/src/share/ob_snapshot_table_proxy.h b/src/share/ob_snapshot_table_proxy.h index 3a1867ebeb8c9b14a00c8d57f6dbcb89d75ca72c..eeb897b2a81634c1313eca6f03298faf48d43573 100644 --- a/src/share/ob_snapshot_table_proxy.h +++ b/src/share/ob_snapshot_table_proxy.h @@ -144,10 +144,9 @@ public: int64_t &count); private: int gen_event_ts(int64_t &event_ts); - int check_snapshot_valid(common::ObISQLClient &client, - const uint64_t tenant_id, + int check_snapshot_valid(const int64_t snapshot_gc_scn, const ObSnapshotInfo &info, - bool &is_valid); + bool &is_valid) const; int fill_snapshot_item(const ObSnapshotInfo &info, share::ObDMLSqlSplicer &dml);