Commit 287f458
[AMORO-4295] AIP-5 Phase 3+4: idle-driven scale-down with graceful drain for dynamic allocation groups (#4296)
* [AMORO-4295] Expose per-token in-flight counts in the dynamic allocation load snapshot
Scale-down needs to know which optimizer instances are busy, not only how
many threads are. Aggregate SCHEDULED/ACKED task counts per optimizer token
in the same scan collectDynamicAllocationLoad() already performs, so one
snapshot supplies both scale directions. Recovered tasks keep their token
across an AMS restart, which makes the very first snapshot after a restart
accurate without any rebuild step.
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
* [AMORO-4295] Add snapshot-derived idle observation and the scale-down decision
Track per-token idle time by observation instead of event counters: each
keeper round feeds the task snapshot into observe(), which refreshes busy
timestamps, seeds first-seen tokens as idle (an instance that never
receives a task must still become removable), and prunes unregistered
ones. Event-maintained counters were rejected because three existing
paths reclaim assigned tasks without any service-level decrement hook
(queue-internal stale-ACKED resets, ack/exec-timeout reclaims of live
optimizers, and process close), each silently inflating a counter until
the instance can never look idle again.
computeScaleDown picks at most one candidate per round: the longest-idle
instance past executor-idle-timeout, rate-limited by scale-down-cooldown,
whose removal keeps registered-minus-draining threads at or above
min-parallelism. Draining threads count as already gone so consecutive
removals cannot pass the floor check together and land below the floor
once they all complete.
validate() now also requires sustained-backlog-timeout to be at most half
of executor-idle-timeout: the keeper cadence is the observation
resolution, and sampling slower than that misjudges an instance that
worked between samples as continuously idle.
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
* [AMORO-4295] Add graceful drain plumbing: poll blocking and optimizer removal
A draining optimizer's token enters a pending-removal set consulted twice
in pollTask: once on entry, and once after the queue poll returns, because
the entry check cannot stop a thread already parked in the queue's
long-poll — it may fetch a task after the drain began, and that task is
handed back (PLANNED again) instead of being assigned. touch/ack/complete
stay open so in-flight tasks finish normally.
executeRemoval releases the container resource, deletes the persisted row,
and unregisters. A missing resource row is handled by releasing through
the optimizer instance itself (it extends Resource and carries the
container identity): a pod that self-registered after a persist failure
has no row and never will, so treating that as a retryable error would
drain-block it forever while its heartbeat keeps it registered. A failed
container release keeps the drain state and retries on a later round —
Kubernetes deletion is idempotent.
The mock container used by the keeper tests now records released
resources and can simulate release failures.
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
* [AMORO-4295] Integrate scale-down and drain progress into the scale keeper round
Each round now runs in a fixed order. Drain progress first and
unconditionally — a drain that completed or hit its deadline converts to
a removal even in rounds that scale up, or a busy drain would linger to
its full timeout while backlog persists. Draining instances are then
accounted as already gone on both sides of the demand math: leaving
their threads in the capacity undercounts demand by up to their thread
count, and leaving their tasks in the load keeps the future-demand
signal (busy >= effective) from ever firing mid-drain. Idle observation
runs every round including scale-up ones, so an instance busy through a
burst does not come out of it looking idle since before the burst began.
Scale-down runs only in rounds with no demand signal at all — including
demand still held back by the backlog gate, which computeScaleUp now
exposes: removing a warm instance right before the gate opens would
free exactly the capacity the next round re-requests. A selected victim
begins a graceful drain and is removed in the same round only if a
snapshot taken after the token entered the pending-removal set shows it
idle; the pre-insert snapshot may miss a task fetched by a long-poll
racing the drain start.
The keeper tests drive rounds with injected times because the validated
minimum executor-idle-timeout (30s) puts real idle waits beyond sane
test durations.
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
* [AMORO-4295] Clear drain state on unregistration and on dynamic allocation disable
Two lifecycle paths could strand a token in the pending-removal set. An
optimizer that dies mid-drain is unregistered by heartbeat expiry, and
its token can never be matched again (the replacement pod registers
under a fresh one), so unregisterOptimizer now clears the drain state.
And a group whose dynamic allocation is disabled mid-drain returns to
the legacy floor keeper, where a leftover drain block would starve the
still-running pod forever — unwatching the group re-admits its tokens
to task assignment.
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
* [AMORO-4295] Fix concurrent optimizer unregistration
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
* [AMORO-4295] Document scale-down and drain behavior in the optimizer group property table
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
---------
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
Co-authored-by: ZhouJinsong <zhoujinsong0505@163.com>1 parent c26fd6e commit 287f458
12 files changed
Lines changed: 1064 additions & 16 deletions
File tree
- amoro-ams/src
- main/java/org/apache/amoro/server
- optimizing
- dra
- test/java/org/apache/amoro/server
- optimizing
- dra
- docs/admin-guides
Lines changed: 229 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
119 | 129 | | |
120 | 130 | | |
121 | 131 | | |
| |||
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
245 | | - | |
246 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
247 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
248 | 267 | | |
249 | 268 | | |
250 | 269 | | |
| |||
269 | 288 | | |
270 | 289 | | |
271 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
272 | 294 | | |
273 | 295 | | |
274 | 296 | | |
275 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
276 | 300 | | |
277 | 301 | | |
278 | 302 | | |
279 | 303 | | |
280 | 304 | | |
281 | 305 | | |
282 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
283 | 403 | | |
284 | 404 | | |
285 | 405 | | |
| |||
1046 | 1166 | | |
1047 | 1167 | | |
1048 | 1168 | | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
1049 | 1175 | | |
1050 | 1176 | | |
1051 | 1177 | | |
| |||
1096 | 1222 | | |
1097 | 1223 | | |
1098 | 1224 | | |
1099 | | - | |
| 1225 | + | |
1100 | 1226 | | |
1101 | 1227 | | |
1102 | 1228 | | |
| |||
1111 | 1237 | | |
1112 | 1238 | | |
1113 | 1239 | | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
1114 | 1315 | | |
1115 | 1316 | | |
1116 | 1317 | | |
| |||
1157 | 1358 | | |
1158 | 1359 | | |
1159 | 1360 | | |
1160 | | - | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
1161 | 1365 | | |
1162 | | - | |
1163 | 1366 | | |
1164 | 1367 | | |
1165 | 1368 | | |
1166 | 1369 | | |
1167 | 1370 | | |
1168 | | - | |
1169 | | - | |
1170 | 1371 | | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1171 | 1387 | | |
1172 | 1388 | | |
1173 | 1389 | | |
1174 | 1390 | | |
1175 | | - | |
| 1391 | + | |
1176 | 1392 | | |
1177 | 1393 | | |
1178 | 1394 | | |
1179 | 1395 | | |
1180 | 1396 | | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
1181 | 1401 | | |
1182 | 1402 | | |
1183 | 1403 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| 431 | + | |
431 | 432 | | |
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
| 437 | + | |
436 | 438 | | |
437 | 439 | | |
438 | 440 | | |
| |||
457 | 459 | | |
458 | 460 | | |
459 | 461 | | |
460 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
461 | 466 | | |
462 | 467 | | |
463 | 468 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
341 | 354 | | |
342 | 355 | | |
343 | 356 | | |
| |||
0 commit comments