@@ -17,6 +17,7 @@ import (
17
17
shared_utils "github.com/aqueducthq/aqueduct/lib/lib_utils"
18
18
"github.com/aqueducthq/aqueduct/lib/models"
19
19
"github.com/aqueducthq/aqueduct/lib/models/shared"
20
+ operator_model "github.com/aqueducthq/aqueduct/lib/models/shared/operator"
20
21
"github.com/aqueducthq/aqueduct/lib/models/shared/operator/param"
21
22
"github.com/aqueducthq/aqueduct/lib/repos"
22
23
"github.com/aqueducthq/aqueduct/lib/vault"
@@ -925,6 +926,11 @@ func (eng *aqEngine) execute(
925
926
926
927
// Kick off execution by starting all operators that don't have any inputs.
927
928
for _ , op := range dag .Operators () {
929
+ log .Infof ("Dag Operator %s [%d], Type: %s" , op .Name (), len (dag .Operators ()), op .Type ())
930
+ if op .Type () == operator_model .LoadType {
931
+ log .Infof ("Skipping save operator %s Type: %s" , op .Name (), op .Type ())
932
+ continue
933
+ }
928
934
if opToDependencyCount [op .ID ()] == 0 {
929
935
inProgressOps [op .ID ()] = op
930
936
}
@@ -952,12 +958,17 @@ func (eng *aqEngine) execute(
952
958
953
959
start := time .Now ()
954
960
961
+ // We defer save operations until all other computer operations are completed successfully.
962
+ // This flag tracks whether the save operations are scheduled for execution.
963
+ loadOpsDone := false
964
+
955
965
for len (inProgressOps ) > 0 {
956
966
if time .Since (start ) > timeConfig .ExecTimeout {
957
967
return errors .Newf ("Reached timeout %s waiting for workflow to complete." , timeConfig .ExecTimeout )
958
968
}
959
969
960
970
for _ , op := range inProgressOps {
971
+ log .Infof ("Operator in progress %s [%d], Type: %s" , op .Name (), len (inProgressOps ), op .Type ())
961
972
if op .Dynamic () && ! op .GetDynamicProperties ().Prepared () {
962
973
err = dynamic .PrepareCluster (
963
974
ctx ,
@@ -1079,26 +1090,45 @@ func (eng *aqEngine) execute(
1079
1090
}
1080
1091
1081
1092
for _ , nextOp := range nextOps {
1093
+
1082
1094
// Decrement the active dependency count for every downstream operator.
1083
1095
// Once this count reaches zero, we can schedule the next operator.
1084
1096
opToDependencyCount [nextOp .ID ()] -= 1
1085
1097
1086
1098
if opToDependencyCount [nextOp .ID ()] < 0 {
1087
- return errors .Newf ("Internal error: operator %s has a negative dependnecy count." , op .Name ())
1099
+ return errors .Newf ("Internal error: operator %s has a negative dependency count." , op .Name ())
1088
1100
}
1089
1101
1090
1102
if opToDependencyCount [nextOp .ID ()] == 0 {
1091
1103
// Defensive check: do not reschedule an already in-progress operator. This shouldn't actually
1092
1104
// matter because we only keep and update a single copy an on operator.
1093
1105
if _ , ok := inProgressOps [nextOp .ID ()]; ! ok {
1094
- inProgressOps [nextOp .ID ()] = nextOp
1106
+ // In this pass only pick pending compute operations, and defer the save operations
1107
+ // to the end.
1108
+ if nextOp .Type () != operator_model .LoadType {
1109
+ inProgressOps [nextOp .ID ()] = nextOp
1110
+ } else {
1111
+ log .Infof ("Skip load operator %s" , nextOp .Name ())
1112
+ }
1095
1113
}
1096
1114
}
1097
1115
}
1098
1116
}
1099
1117
1100
1118
time .Sleep (timeConfig .OperatorPollInterval )
1101
1119
}
1120
+ // There are no more computer operations to run. Run the save (load) operations to persist
1121
+ // artifacts to DB. The save operations are scheduled at the end so data is persisted only if
1122
+ // all preceding compute operations are successful.
1123
+ if len (inProgressOps ) == 0 && ! loadOpsDone {
1124
+ for _ , saveOp := range workflowDag .Operators () {
1125
+ if saveOp .Type () == operator_model .LoadType {
1126
+ log .Infof ("Scheduling load operator %s for execution" , saveOp .Name ())
1127
+ inProgressOps [saveOp .ID ()] = saveOp
1128
+ }
1129
+ }
1130
+ loadOpsDone = true
1131
+ }
1102
1132
}
1103
1133
1104
1134
if len (completedOps ) != len (dag .Operators ()) {
0 commit comments