alamb commented on issue #19905:
URL: https://github.com/apache/datafusion/issues/19905#issuecomment-7281930784

   I spent some time researching this issue. I think the core problem is what 
@adriangb  identified
   
   > reset_plan_states has two callers that want opposite things.
   
   <img width="875" height="571" alt="Screenshot 2026-11-30 at 9 21 25 AM" 
src="https://github.com/user-attachments/assets/aa70a0c9-5f4d-4049-ad85-4c5cb9034020";
 />
   
   Specifically I think when that picture shows "copy" it means 
`Arc::clone(...)` which isn't really a copy.  (this is basically what @askalt 
was trying to separate in #19462 I think). 
   
   Given that the ExecutionPlans do have state, I think we need to separate the 
notions of:
   1. Sequential reuse of the same `ExecutionPlan` (aka 
`ExecutionPlan::reset_state`)
   2. Concurrent reuse /  independent execution of the the same `ExecutionPlan`
   
   Thus I propose behavior:
   1. `reset_state` clears the dynamic filter state from producers but keeps 
consumers connected (not this will **NOT** support concurrently executing a 
plan)
   2. Add another mechanism to support "deep copy" an execution plan for 
concurrent execution (seems restate / @AhmedSoliman  did this explicitly 
downstream 
[here](https://github.com/restatedev/restate/blob/91e74b576fd6e9c6b05236db4c49ca92aa4c4306/crates/distributed-datafusion/src/distributed/partition_reads.rs#L433-L436),
 but that requires having their own scan implementation)
   
   We would also have to update https://github.com/apache/datafusion/pull/27453 
from @raghavyadav01  so that it didn't retarget the dynsmic filters
   
   I will also add some documentation PRs to try and clarify that calling 
`execute` on the same `ExecutionPlan`, even after calling 
`reset_states`/`reset_plan_states` is not supported as the plans may share 
state. Only after the execution has completed, can we safely call `reset_state` 
and run it again.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to