Commit c577675
committed
fix: concurrency drain timer resumes outside lock
A map or parallel stays in the current invocation while at least one
branch is still running. When one iteration keeps it alive and the
other branches wait on short timers (a wait, a wait_for_condition poll,
or a step retry backoff), those branches resume in-process as their
timers come due.
Before this commit, a single timer thread runs those resumes one at a
time and holds its lock across a blocking checkpoint that refreshes
state. Every resume costs one network round trip under the lock, and
every branch trying to register its next wait queues behind it. When
many timers come due together the timer thread falls behind, the
invocation reaches its function timeout, and the backend reinvokes, so
a map that should finish in seconds runs for minutes across several
timed-out invocations. Holding the lock across the submit also allowed
a latent self-deadlock, where a branch that finished inline reacquired
the same lock on the timer thread through its done-callback.
This commit holds the lock only long enough to take all due timers off
the queue and mark them pending, then releases it and runs one shared
refresh for the whole wave before handing the branches back to the
worker pool. One round trip now serves the whole wave instead of one
per resume, and new waits no longer queue behind a network call. The
take and the mark stay atomic so a branch never looks parked while it
is about to resume, which would otherwise suspend the whole operation
by mistake. If the refresh fails, which happens only when the
checkpoint subsystem has already failed and is terminal, the timer
thread records that one error and re-raises it from execute() so the
platform retries from the last checkpoint.
Closes #4731 parent cd51a60 commit c577675
2 files changed
Lines changed: 123 additions & 12 deletions
File tree
- packages/aws-durable-execution-sdk-python
- src/aws_durable_execution_sdk_python/concurrency
- tests
Lines changed: 52 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
118 | 124 | | |
119 | | - | |
120 | | - | |
121 | | - | |
| 125 | + | |
122 | 126 | | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
128 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
129 | 142 | | |
130 | 143 | | |
131 | 144 | | |
| |||
169 | 182 | | |
170 | 183 | | |
171 | 184 | | |
| 185 | + | |
172 | 186 | | |
173 | 187 | | |
174 | 188 | | |
| |||
222 | 236 | | |
223 | 237 | | |
224 | 238 | | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
230 | 265 | | |
231 | 266 | | |
232 | 267 | | |
| |||
259 | 294 | | |
260 | 295 | | |
261 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
262 | 303 | | |
263 | 304 | | |
264 | 305 | | |
| |||
Lines changed: 71 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1370 | 1370 | | |
1371 | 1371 | | |
1372 | 1372 | | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1373 | 1441 | | |
1374 | 1442 | | |
1375 | 1443 | | |
| |||
3200 | 3268 | | |
3201 | 3269 | | |
3202 | 3270 | | |
3203 | | - | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
3204 | 3274 | | |
3205 | 3275 | | |
3206 | 3276 | | |
| |||
0 commit comments