@@ -274,6 +274,12 @@ func ProcessTableConfigurations(tfmContext FlowMachineContext, tfContext FlowCon
274274}
275275
276276func ProcessFlowStatesForInterval (tfContext FlowContext , tfmContext FlowMachineContext , flowDefinitionContext * FlowLibraryContext , regionList []string ) int {
277+ // Acquire the pullOnceMu so that synchronous ExecuteFilteredPullOnce calls block
278+ // all async push/pull activity for this flow until they complete.
279+ mu := tfContext .GetPullOnceMu ()
280+ mu .Lock ()
281+ defer mu .Unlock ()
282+
277283 if tfContext .GetFlowStateState () == 3 {
278284 tfContext .SetRestart (false )
279285 tfmContext .SetPermissionUpdate (tfContext )
@@ -331,12 +337,6 @@ func ProcessFlowStatesForInterval(tfContext FlowContext, tfmContext FlowMachineC
331337 return 0
332338 }
333339
334- // Acquire the pullOnceMu so that synchronous ExecuteFilteredPullOnce calls block
335- // all async push/pull activity for this flow until they complete.
336- mu := tfContext .GetPullOnceMu ()
337- mu .Lock ()
338- defer mu .Unlock ()
339-
340340 // Logic for push/pull once
341341 if tfContext .FlowSyncModeMatch ("push" , true ) {
342342 switch syncSuffix := strings .TrimPrefix (tfContext .GetFlowSyncMode (), "push" ); syncSuffix {
@@ -484,6 +484,14 @@ func ExecuteFilteredPullOnce(tfmContext FlowMachineContext, tfContext FlowContex
484484 return
485485 }
486486
487+ // Acquire the mutex before mutating state so the async path cannot race with us.
488+ mu := tfContext .GetPullOnceMu ()
489+ mu .Lock ()
490+ defer mu .Unlock ()
491+
492+ tfContext .SetFlowSyncFilter (syncFilter )
493+ tfContext .SetFlowSyncMode ("pullonce" )
494+
487495 var tableIndexKey string
488496 if flowDefinitionContext .GetTableIndexColumnNames != nil {
489497 if keys := flowDefinitionContext .GetTableIndexColumnNames (); len (keys ) == 1 {
@@ -495,14 +503,6 @@ func ExecuteFilteredPullOnce(tfmContext FlowMachineContext, tfContext FlowContex
495503 return
496504 }
497505
498- // Acquire the mutex before mutating state so the async path cannot race with us.
499- mu := tfContext .GetPullOnceMu ()
500- mu .Lock ()
501- defer mu .Unlock ()
502-
503- tfContext .SetFlowSyncFilter (syncFilter )
504- tfContext .SetFlowSyncMode ("pullonce" )
505-
506506 tableConfigurations , err := tableConfigurationFlowPullRemote (tfmContext , tfContext )
507507 if err != nil {
508508 tfmContext .Log ("ExecuteFilteredPullOnce: error pulling configurations" , err )
@@ -533,6 +533,7 @@ func ExecuteFilteredPullOnce(tfmContext FlowMachineContext, tfContext FlowContex
533533 }
534534 }
535535
536+ tfContext .SetFlowSyncFilter ("" )
536537 tfContext .SetFlowSyncMode ("pullcomplete" )
537538 tfContext .PushState ("flowStateReceiver" , tfContext .NewFlowStateUpdate ("2" , "pullcomplete" ))
538539}
0 commit comments