@@ -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
869870int 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 }
0 commit comments