delete batch records when try_gc_tablet_checksum
This commit is contained in:
@ -37,7 +37,6 @@ ObDailyMajorFreezeLauncher::ObDailyMajorFreezeLauncher()
|
||||
already_launch_(false),
|
||||
config_(nullptr),
|
||||
gc_freeze_info_last_timestamp_(0),
|
||||
gc_tablet_ckm_last_timestamp_(0),
|
||||
freeze_info_mgr_(nullptr)
|
||||
{
|
||||
}
|
||||
@ -56,7 +55,6 @@ int ObDailyMajorFreezeLauncher::init(
|
||||
tenant_id_ = tenant_id;
|
||||
config_ = &config;
|
||||
gc_freeze_info_last_timestamp_ = ObTimeUtility::current_time();
|
||||
gc_tablet_ckm_last_timestamp_ = ObTimeUtility::current_time();
|
||||
freeze_info_mgr_ = &freeze_info_manager;
|
||||
sql_proxy_ = &proxy;
|
||||
already_launch_ = false;
|
||||
@ -199,12 +197,11 @@ int ObDailyMajorFreezeLauncher::try_gc_tablet_checksum()
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t MIN_RESERVED_COUNT = 8;
|
||||
int64_t now = ObTimeUtility::current_time();
|
||||
const static int64_t BATCH_DELETE_CNT = 2000;
|
||||
|
||||
if (OB_UNLIKELY(IS_NOT_INIT || OB_ISNULL(sql_proxy_))) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not init", KR(ret), K_(is_inited));
|
||||
} else if ((now - gc_tablet_ckm_last_timestamp_) < MODIFY_GC_INTERVAL) {
|
||||
// nothing
|
||||
} else {
|
||||
ObMySQLTransaction trans;
|
||||
SMART_VAR(ObArray<SCN>, all_compaction_scn) {
|
||||
@ -217,7 +214,8 @@ int ObDailyMajorFreezeLauncher::try_gc_tablet_checksum()
|
||||
const int64_t snapshot_ver_cnt = all_compaction_scn.count();
|
||||
const SCN &gc_snapshot_scn = all_compaction_scn.at(snapshot_ver_cnt - MIN_RESERVED_COUNT - 1);
|
||||
|
||||
if (OB_FAIL(ObTabletChecksumOperator::delete_tablet_checksum_items(trans, tenant_id_, gc_snapshot_scn))) {
|
||||
if (OB_FAIL(ObTabletChecksumOperator::delete_tablet_checksum_items(trans, tenant_id_, gc_snapshot_scn,
|
||||
BATCH_DELETE_CNT))) {
|
||||
LOG_WARN("fail to delete tablet checksum items", KR(ret), K_(tenant_id), K(gc_snapshot_scn));
|
||||
}
|
||||
}
|
||||
@ -230,10 +228,6 @@ int ObDailyMajorFreezeLauncher::try_gc_tablet_checksum()
|
||||
LOG_WARN("fail to end trans", "is_commit", OB_SUCCESS == ret, KR(tmp_ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
gc_tablet_ckm_last_timestamp_ = now;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ private:
|
||||
bool already_launch_;
|
||||
common::ObServerConfig *config_;
|
||||
int64_t gc_freeze_info_last_timestamp_;
|
||||
int64_t gc_tablet_ckm_last_timestamp_;
|
||||
ObFreezeInfoManager *freeze_info_mgr_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ObDailyMajorFreezeLauncher);
|
||||
|
@ -494,24 +494,26 @@ int ObTabletChecksumOperator::insert_or_update_tablet_checksum_items_(
|
||||
int ObTabletChecksumOperator::delete_tablet_checksum_items(
|
||||
ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const SCN &gc_compaction_scn)
|
||||
const SCN &gc_compaction_scn,
|
||||
const int64_t limit_cnt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSqlString sql;
|
||||
int64_t affected_rows = 0;
|
||||
const uint64_t extract_tenant_id = 0;
|
||||
const uint64_t gc_scn_val = gc_compaction_scn.is_valid() ? gc_compaction_scn.get_val_for_inner_table_field() : 0;
|
||||
if (OB_UNLIKELY((!is_valid_tenant_id(tenant_id)))
|
||||
|| (!gc_compaction_scn.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(gc_compaction_scn));
|
||||
} else if (OB_FAIL(sql.assign_fmt("DELETE FROM %s WHERE tenant_id = '%lu' AND compaction_scn <= %lu",
|
||||
OB_ALL_TABLET_CHECKSUM_TNAME, extract_tenant_id,
|
||||
gc_compaction_scn.is_valid() ? gc_compaction_scn.get_val_for_inner_table_field() : 0))) {
|
||||
LOG_WARN("fail to assign sql", KR(ret), K(tenant_id), K(gc_compaction_scn));
|
||||
} else if (OB_FAIL(sql.assign_fmt("DELETE FROM %s WHERE tenant_id = '%lu' AND compaction_scn <= %lu"
|
||||
" AND NOT (tablet_id=%ld AND ls_id=%ld) limit %ld", OB_ALL_TABLET_CHECKSUM_TNAME, extract_tenant_id,
|
||||
gc_scn_val, ObTabletID::MIN_VALID_TABLET_ID, ObLSID::SYS_LS_ID, limit_cnt))) {
|
||||
LOG_WARN("fail to assign sql", KR(ret), K(tenant_id), K(gc_compaction_scn), K(limit_cnt));
|
||||
} else if (OB_FAIL(sql_client.write(tenant_id, sql.ptr(), affected_rows))) {
|
||||
LOG_WARN("fail to execute sql", KR(ret), K(sql));
|
||||
} else {
|
||||
LOG_TRACE("succ to delete tablet checksum items", K(tenant_id), K(gc_compaction_scn), K(affected_rows));
|
||||
LOG_INFO("succ to delete tablet checksum items", K(tenant_id), K(gc_compaction_scn), K(affected_rows), K(limit_cnt));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -99,11 +99,13 @@ public:
|
||||
common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
common::ObIArray<ObTabletChecksumItem> &items);
|
||||
// delete all records whose 'snapshot_version' <= min_snapshot_version
|
||||
// delete limited records whose 'snapshot_version' <= min_snapshot_version
|
||||
// , while the record of whose (tablet_id, ls_id) is (1, 1) can't be deleted.
|
||||
static int delete_tablet_checksum_items(
|
||||
common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const SCN &gc_compaction_scn);
|
||||
const SCN &gc_compaction_scn,
|
||||
const int64_t limit_cnt);
|
||||
static int delete_tablet_checksum_items(
|
||||
common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
|
Reference in New Issue
Block a user