Hi, I have filed JIRA ticket SPARK-59160 <https://issues.apache.org/jira/browse/SPARK-59160> . It is not a bug afaik right now , but has potential in future to result in nasty situation. The issue is that AdaptiveSparkPlan uses cached stages of subplans via the AdaptiveContext, while the current stage ID of each AdaptiveSparkPlanExec initializes from 0. This means the stage Ids are bound to conflict. At this point in code, no lookups or checks involve stageIDs ( use canonicalized plans), so no issues. But if code in future changes to rely on Ids somewhere , bugs will appear ( I saw it causing trouble in my changes). The fix is to move the stageID generation to AdaptiveExecutionontext for uniqueness and use atomic int ( as concurrent access a possibility). If it is deemed as valid improvement, I wanted to share this tracking information to minimize any inadvertent duplication and ensure they are resolved using the original JIRA and PR.
Regards Asif
