Skip to content

Conversation

@waltertan1988
Copy link

@waltertan1988 waltertan1988 commented Nov 4, 2025

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

The description of the PR:
【背景】通过xxljob的分片广播特性加速生成数据,在某些业务场景下,仅靠计算分片信息(shardIndex和shardTotal)可能会容易产生分片数据倾斜(即一些分片实例很快执行完,而另一些却执行很慢)。比如业务方有一个t_task表,里面记录了一个个待执行的任务,但每一个t_task.id背后所需要执行的时间差异很大且不好预估(这取决于每个t_task.id背后各自所需的数据量)。

【思路】分片执行时,不依赖于shardIndex和shardTotal,而是改为使用一个带”执行版本”的乐观锁机制,且这个”执行版本“应该由xxljob-admin统一提供给各个执行器分片使用,每个分片实例都扫描每一个t_task记录,并以乐观锁的”抢占式+一次性“特性来执行。而这个统一的”执行版本“,最直观的一种实现方式就是使用由xxljob-admin触发作业时的时间戳(即:com.xxl.job.core.openapi.model.TriggerRequest#logDateTime)

【问题】当前最新版本的xxljob(2025.11.04的master分支),在com.xxl.job.core.context.XxlJobHelper和com.xxl.job.core.context.XxlJobContext中都没有提供获取触发该作业的时间戳。

本PR正是希望实现执行器获取job的触发时间戳的功能,请帮忙review一下代码,谢谢。

Other information:
相关Issue:Issue-3481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant