Skip to content

Commit db193dd

Browse files
shenyunlongob-robot
authored andcommitted
[CP] [OBKV] Fix TTL issue 52477968 & 52561826 & 52557010
1 parent d98b7cf commit db193dd

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/observer/table/ttl/ob_tenant_tablet_ttl_mgr.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,10 @@ int ObTenantTabletTTLMgr::get_ttl_para_from_schema(const schema::ObTableSchema *
866866
return ret;
867867
}
868868

869+
// task already lock in ObTenantTabletTTLMgr::sync_sys_table
869870
int ObTenantTabletTTLMgr::try_schedule_prepare_task(ObTabletID& tablet_id)
870871
{
871872
int ret = OB_SUCCESS;
872-
common::ObSpinLockGuard guard(lock_);
873873
ObTTLTaskCtx* ctx = get_one_tablet_ctx(tablet_id);
874874
if (OB_ISNULL(ctx)) {
875875
ret = OB_ERR_NULL_VALUE;
@@ -920,6 +920,8 @@ int ObTenantTabletTTLMgr::sync_sys_table(ObTabletID& tablet_id)
920920
}
921921

922922
// lock task ctx for update
923+
// must not hold lock_ any more in this following code, which will cause deadlock
924+
// beause dag thread hold lock_ first, and ctx->lock_ second at report_task_status
923925
common::ObSpinLockGuard ctx_guard(ctx->lock_);
924926
if (OB_SUCC(ret) && OB_UNLIKELY(ctx->need_refresh_)) {
925927
switch (ctx->task_status_) {
@@ -1195,10 +1197,13 @@ int ObTenantTabletTTLMgr::try_schedule_remaining_tasks(const ObTTLTaskCtx *curre
11951197
LOG_ERROR("fatal err, ttl ctx in map is null", KR(ret), K(local_tenant_task_.tenant_id_));
11961198
} else if (current_ctx == ctx) {
11971199
// do nothing
1198-
} else if (can_schedule_task(*ctx)) {
1199-
if (OB_FAIL(try_schedule_task(ctx))) {
1200-
if (OB_SIZE_OVERFLOW != ret) {
1201-
LOG_WARN("fail to schedule task", KR(ret));
1200+
} else {
1201+
common::ObSpinLockGuard guard(ctx->lock_);
1202+
if (can_schedule_task(*ctx)) {
1203+
if (OB_FAIL(try_schedule_task(ctx))) {
1204+
if (OB_SIZE_OVERFLOW != ret) {
1205+
LOG_WARN("fail to schedule task", KR(ret));
1206+
}
12021207
}
12031208
}
12041209
}

src/observer/table/ttl/ob_tenant_ttl_manager.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ int ObTTLTaskScheduler::try_add_periodic_task()
409409
if (tenant_task_.is_finished_ && OB_FAIL(add_ttl_task_internal(TRIGGER_TYPE::PERIODIC_TRIGGER))) {
410410
LOG_WARN("fail to add ttl task", KR(ret), K_(tenant_id));
411411
} else {
412-
periodic_launched_ = false;
412+
periodic_launched_ = true;
413413
}
414414
}
415415
} else {
@@ -739,7 +739,10 @@ int ObTTLTaskScheduler::check_all_tabelt_finished(bool &all_finished)
739739
const int64_t table_id = table_id_array.at(idx);
740740
const ObTableSchema *table_schema = nullptr;
741741
if (OB_FAIL(schema_guard.get_table_schema(tenant_id_, table_id, table_schema))) {
742-
LOG_WARN("failed to get simple schema", KR(ret), K(table_id));
742+
LOG_WARN("fail to get simple schema", KR(ret), K(table_id));
743+
} else if (OB_ISNULL(table_schema)) {
744+
ret = OB_TABLE_NOT_EXIST;
745+
LOG_WARN("table schema is null", KR(ret), K(table_id));
743746
} else if (OB_FAIL(ObTTLUtil::check_is_ttl_table(*table_schema, is_ttl_table))) {
744747
LOG_WARN("fail to check is ttl table", KR(ret));
745748
} else if (is_ttl_table) {

0 commit comments

Comments
 (0)