sleep 20 second when xa gc invalid record
This commit is contained in:
parent
93292ad68d
commit
6fe3cf36b0
@ -71,34 +71,42 @@ void ObXAInnerTableGCWorker::run1()
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr int64_t gc_interval_upper_bound = 24L * (3600L * 1000L * 1000L); //upper bound is 24h
|
||||||
int64_t tmp_start_delay = GCONF._xa_gc_interval; // default is 3600 000 000
|
int64_t tmp_start_delay = GCONF._xa_gc_interval; // default is 3600 000 000
|
||||||
int64_t gc_interval = std::max(2 * max_gc_cost_time_, tmp_start_delay);
|
int64_t gc_interval = std::max(2 * max_gc_cost_time_, tmp_start_delay);
|
||||||
|
gc_interval = std::min(gc_interval, gc_interval_upper_bound);
|
||||||
|
|
||||||
int64_t gc_cost_time = 0;
|
int64_t gc_cost_time = 0;
|
||||||
int64_t before_gc_ts = 0;
|
int64_t before_gc_ts = 0;
|
||||||
|
|
||||||
while (!has_set_stop()) {
|
while (!has_set_stop()) {
|
||||||
before_gc_ts = ObTimeUtil::current_time();
|
before_gc_ts = ObTimeUtil::current_time();
|
||||||
if (before_gc_ts - last_scan_ts > gc_interval) {
|
if (before_gc_ts - last_scan_ts > gc_interval) {
|
||||||
if (is_user_tenant(tenant_id) && OB_SUCC(share::ObCompatModeGetter::check_is_oracle_mode_with_tenant_id(tenant_id, is_oracle_mode)) && is_oracle_mode) {
|
if (is_user_tenant(tenant_id)
|
||||||
|
&& OB_SUCC(share::ObCompatModeGetter::check_is_oracle_mode_with_tenant_id(tenant_id, is_oracle_mode))
|
||||||
|
&& is_oracle_mode) {
|
||||||
if (OB_FAIL(xa_service_->gc_invalid_xa_record(tenant_id))) {
|
if (OB_FAIL(xa_service_->gc_invalid_xa_record(tenant_id))) {
|
||||||
TRANS_LOG(WARN, "gc invalid xa record failed", K(ret), K(tenant_id));
|
TRANS_LOG(WARN, "gc invalid xa record failed", K(ret), K(tenant_id),
|
||||||
|
K(gc_interval), K(last_scan_ts), K(before_gc_ts));
|
||||||
} else {
|
} else {
|
||||||
// update last scan ts
|
// update last scan ts
|
||||||
last_scan_ts = ObTimeUtil::current_time();
|
last_scan_ts = ObTimeUtil::current_time();
|
||||||
gc_cost_time = last_scan_ts - before_gc_ts;
|
gc_cost_time = last_scan_ts - before_gc_ts; // compute gc cost
|
||||||
max_gc_cost_time_ = std::max(max_gc_cost_time_, gc_cost_time);
|
max_gc_cost_time_ = std::max(max_gc_cost_time_, gc_cost_time);
|
||||||
TRANS_LOG(INFO, "scan xa inner table for one round", K(tenant_id), K(ret), K(gc_cost_time));
|
TRANS_LOG(INFO, "scan xa inner table for one round", K(tenant_id), K(ret), K(gc_cost_time));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
last_scan_ts = before_gc_ts;
|
last_scan_ts = before_gc_ts;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
sleep(1);//1 seconds
|
|
||||||
// try refresh gc_interval
|
|
||||||
tmp_start_delay = GCONF._xa_gc_interval;
|
|
||||||
// gc interval mini value is (2 * 10s)
|
|
||||||
gc_interval = std::max(2 * max_gc_cost_time_, tmp_start_delay);
|
|
||||||
}
|
}
|
||||||
|
//sleep 20 secnd whether gc succ or not
|
||||||
|
sleep(20);
|
||||||
|
// try refresh gc_interval,
|
||||||
|
// if gc falied, and not update last_scan_ts, update gc_interval can be effective
|
||||||
|
// gc_interval ~ [20s, 24h]
|
||||||
|
tmp_start_delay = GCONF._xa_gc_interval;
|
||||||
|
gc_interval = std::max(2 * max_gc_cost_time_, tmp_start_delay); // gc interval mini value is (2 * 10s)
|
||||||
|
gc_interval = std::min(gc_interval, gc_interval_upper_bound);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user