[WIP] Fix timezone round-trip bug in BackfillWorkflowExecutorDelegate#3
Closed
[WIP] Fix timezone round-trip bug in BackfillWorkflowExecutorDelegate#3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.
Original prompt
Background
PR apache#18003 (apache/dolphinscheduler) implements downstream-dependent backfill triggering in
BackfillWorkflowExecutorDelegate. There are two remaining issues that must be fixed without introducing any new problems:Issue 1 — Timezone round-trip bug (functional bug, highest priority)
File:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/BackfillWorkflowExecutorDelegate.javaRoot cause:
doBackfillDependentWorkflowcurrently acceptsList<String> backfillTimeList(date strings), then converts them back toZonedDateTimeviaDateUtils.stringToZoneDateTime. This creates a string→ZonedDateTime round-trip. BecausestringToZoneDateTimeparses usingZoneId.systemDefault(), the timezone can shift when the request timezone differs from the JVM default, causing downstream workflows to be backfilled for wrong business dates.Fix:
doBackfillDependentWorkflowto acceptList<ZonedDateTime> backfillDateListinstead ofList<String> backfillTimeListZonedDateTimelist directly to the downstreamBackfillParamsDTO.backfillDateList, eliminating the string→ZonedDateTime conversion entirelydoBackfillWorkflow, instead of passingbackfillTimeList(strings), pass the originalZonedDateTimelist. TheZonedDateTimelist is available frombackfillWorkflowDTO.getBackfillParams().getBackfillDateList()— but note that in the serial path the list has already been sorted (indoSerialBackfillWorkflow), and in the parallel path each chunk is a sub-list ofZonedDateTime. So the correct approach is to pass theZonedDateTimechunk/list intodoBackfillWorkflow, and then pass it along todoBackfillDependentWorkflow.Concretely:
doBackfillWorkflowto also acceptList<ZonedDateTime> backfillDateListalongsideList<String> backfillTimeList— OR store the ZonedDateTime list on the DTO so it is available indoBackfillWorkflow. The cleanest approach: changedoBackfillWorkflowto receive bothList<ZonedDateTime> backfillDateListandList<String> backfillTimeList(the string list is still needed for the trigger request to master), and passbackfillDateListthrough todoBackfillDependentWorkflow.doSerialBackfillWorkflow: passbackfillTimeList(the sorted ZonedDateTime list) plus the string conversion todoBackfillWorkflow.doParallelBackfillWorkflow: passstringDate(the ZonedDateTime chunk) plus the string conversion todoBackfillWorkflow.doBackfillDependentWorkflow: remove theDateUtils.stringToZoneDateTimeconversion; use the passed-inZonedDateTimelist directly asbackfillDateListindependentParams.DateUtilsimport if it is no longer needed (check —DateUtils::dateToStringis still used, so keep the import).Issue 2 — Reflection-based test access (brittle tests)
File:
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/executor/workflow/BackfillWorkflowExecutorDelegateTest.javaRoot cause: All tests that exercise
doBackfillDependentWorkflowusegetDeclaredMethod+setAccessible(true)to call the private method. This is brittle: any rename or signature change silently breaks tests.Fix:
doBackfillDependentWorkflowin the production class fromprivateto package-private (no modifier) — it is in the same package as the testgetDeclaredMethod/setAccessible/method.invoke(...)block with a direct call tobackfillWorkflowExecutorDelegate.doBackfillDependentWorkflow(...)import java.lang.reflect.Method;import from the test file since it will no longer be neededThe method signature after the timezone fix (Issue 1) will be:
Tests must be updated to pass
List<ZonedDateTime>instead ofList<String>when callingdoBackfillDependentWorkflow.Issue 3 — PR description not updated
File: PR body (not a source file — skip this, it is handled separately)
Constraints
execute,executeWithVisitedCodes,triggerBackfillWorkflow)List<String>toList<ZonedDateTime>processServiceandcommandDaofields as-is (they exist in the class, don't remove them)DateUtilsimport must remain (still used forDateUtils::dateToString)LinkedHashSetimport may still be needed (used indoBackfillDependentWorkflowfordownstreamCodes)This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.