Commit 8bd7c03
feat: implement module scheduling constraints and enhance scheduler (#1304)
* refactor: enhance module execution with eager parallel scheduling and improved state management
* feat: implement module scheduling constraints and enhance scheduler functionality
* refactor: optimize blocking module search by converting values to a list
* refactor: improve module state properties with volatile fields for thread safety
* refactor: unify module state management by replacing boolean flags with an enum for clarity and consistency
* feat: add detailed logging for module execution and queuing states
* refactor: enhance constraint checking in module execution with improved logging and state consistency
* fix: improve constraint checking with state snapshot and comprehensive debug logging
- Snapshot all module states before filtering to ensure consistent view
- Add detailed debug logging for constraint checking to diagnose race conditions
- Change all diagnostic logs to LogDebug level
- Log active module comparisons, lock key intersections, and blocking decisions
* fix: exclude self from constraint checks in module scheduling
* fix: use tracking collections for constraint checking
Fixes race condition in constraint checking by using the tracking
collections (_queuedModules and _executingModules) directly instead
of filtering by State enum. This prevents the issue where State changes
during iteration would be immediately visible through list references,
causing inconsistent constraint evaluation.
Changes:
- Replace state-based filtering with direct collection usage
- Add self-exclusion checks to prevent modules comparing against themselves
- Remove snapshot approach that created references to mutable state
This ensures modules with conflicting lock keys are properly blocked
from parallel execution, preventing the race condition that allowed
Module2 and Module3 (both with lock key "B") to execute concurrently.
Fixes #1304
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: simplify long-running module execution by removing timeout handling
* fix: respect engine cancellation in module execution task handling
* fix: add timeout handling for LongRunningModule to ensure cancellation behavior
* fix: correct await usage in timeout handling for module execution
* fix: prevent unobserved task exceptions by observing executeAsyncTask's exception in timeout handling
* fix: add defensive constraint check at execution boundary to prevent race conditions
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 32a2785 commit 8bd7c03
File tree
17 files changed
+1171
-310
lines changed- src/ModularPipelines
- Context
- DependencyInjection
- Engine
- Constraints
- Modules
- Options
- test/ModularPipelines.UnitTests
17 files changed
+1171
-310
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
14 | 27 | | |
15 | 28 | | |
| 29 | + | |
| 30 | + | |
16 | 31 | | |
17 | 32 | | |
18 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
19 | 38 | | |
20 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
21 | 51 | | |
22 | 52 | | |
23 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
24 | 57 | | |
25 | 58 | | |
26 | 59 | | |
27 | 60 | | |
28 | 61 | | |
29 | 62 | | |
30 | 63 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
37 | 67 | | |
38 | 68 | | |
39 | 69 | | |
40 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
41 | 74 | | |
42 | 75 | | |
43 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
44 | 79 | | |
45 | 80 | | |
46 | 81 | | |
47 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
48 | 86 | | |
49 | 87 | | |
50 | 88 | | |
51 | | - | |
| 89 | + | |
52 | 90 | | |
53 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
54 | 95 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
59 | 99 | | |
60 | 100 | | |
61 | | - | |
| 101 | + | |
62 | 102 | | |
63 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
64 | 107 | | |
65 | 108 | | |
66 | 109 | | |
67 | 110 | | |
68 | 111 | | |
69 | 112 | | |
70 | 113 | | |
71 | | - | |
| 114 | + | |
72 | 115 | | |
73 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
74 | 121 | | |
75 | 122 | | |
76 | | - | |
| 123 | + | |
77 | 124 | | |
78 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
79 | 129 | | |
80 | 130 | | |
81 | | - | |
| 131 | + | |
82 | 132 | | |
83 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
84 | 143 | | |
85 | 144 | | |
86 | 145 | | |
| |||
97 | 156 | | |
98 | 157 | | |
99 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
100 | 163 | | |
101 | | - | |
| 164 | + | |
102 | 165 | | |
103 | | - | |
| 166 | + | |
104 | 167 | | |
105 | 168 | | |
106 | | - | |
| 169 | + | |
107 | 170 | | |
108 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
109 | 176 | | |
110 | 177 | | |
111 | | - | |
| 178 | + | |
112 | 179 | | |
113 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
114 | 188 | | |
115 | 189 | | |
116 | 190 | | |
117 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
118 | 195 | | |
119 | 196 | | |
120 | 197 | | |
121 | 198 | | |
122 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
123 | 203 | | |
124 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
125 | 209 | | |
126 | | - | |
| 210 | + | |
127 | 211 | | |
128 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
129 | 216 | | |
130 | 217 | | |
131 | 218 | | |
| 219 | + | |
| 220 | + | |
132 | 221 | | |
133 | 222 | | |
134 | 223 | | |
| |||
149 | 238 | | |
150 | 239 | | |
151 | 240 | | |
| 241 | + | |
| 242 | + | |
152 | 243 | | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| 134 | + | |
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
0 commit comments