Commit d26bbfe
committed
Restore __del__ safety-net cleanup on SyncWrapper + PublishServer + _TCPPubServerPublisher (#70175)
Extends the "warn + fall back to close()" pattern from commit 9955b89
(``salt.utils.event.SaltEvent.__del__``) to the three sub-classes ``SaltEvent``
composes with:
* ``salt.utils.asynchronous.SyncWrapper.__del__``
* ``salt.transport.tcp.PublishServer.__del__``
* ``salt.transport.tcp._TCPPubServerPublisher.__del__``
Each ``__del__`` still emits the ``ResourceWarning`` via
``salt.utils.resource_warnings.warn_until_close`` (so leaky callers keep
surfacing for pre-Potassium tracking), then falls back to ``close()``
wrapped in try/except so a finalizer never propagates. For
``PublishServer.close`` the individual sub-resource close steps
(``pub_sock``, ``pub_server``, ``pull_sock``, ``io_loop.stop``,
``io_loop.close``) are additionally guarded, because they can raise
during GC-time execution when the io_loop is in a partially torn-down
state -- which is exactly the failure mode driving ~50 MB/hr RSS
growth on the minion under sustained event traffic.
Companion to sibling branches ``dwoz/fix/70175-pubserver-perjob-leak``,
``dwoz/fix/70175-saltevent-caller-close``,
``dwoz/fix/70175-receive-path-saltevent`` and to shutdown-path fix #70206.
The ``master`` (Potassium) branch drops the ``close()`` fallback and
requires explicit ``close()`` / context-manager use; the loud
``ResourceWarning`` here is the migration signal for that change.
Regression tests:
* tests/pytests/unit/utils/test_asynchronous.py::test_syncwrapper_del_safety_net_calls_close_70175
* tests/pytests/unit/transport/test_tcp.py::test_publish_server_del_safety_net_calls_close_70175
* tests/pytests/unit/transport/test_tcp.py::test_tcppubserverpublisher_del_safety_net_calls_close_70175
Each test:
1. Instantiates the class without ``with``, drops the reference, forces GC
2. Asserts the ``ResourceWarning`` still fires (behavior preserved)
3. Asserts a class-appropriate observable that only ``close()`` would
set (asyncio_loop.is_closed() for SyncWrapper; sub-resource
``close()`` mock calls for PublishServer; stream+socket close for
_TCPPubServerPublisher)
All three tests fail on pre-patch origin/3008.x with only the
``ResourceWarning`` firing, and pass with the safety-net restored.
Refs #70175, #70206.1 parent 0399687 commit d26bbfe
5 files changed
Lines changed: 299 additions & 28 deletions
File tree
- changelog
- salt
- transport
- utils
- tests/pytests/unit
- transport
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2341 | 2341 | | |
2342 | 2342 | | |
2343 | 2343 | | |
2344 | | - | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
2345 | 2347 | | |
2346 | 2348 | | |
2347 | | - | |
2348 | | - | |
2349 | | - | |
2350 | | - | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
2351 | 2356 | | |
2352 | 2357 | | |
2353 | 2358 | | |
| |||
2383 | 2388 | | |
2384 | 2389 | | |
2385 | 2390 | | |
2386 | | - | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
2387 | 2395 | | |
2388 | 2396 | | |
2389 | | - | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
2390 | 2401 | | |
2391 | 2402 | | |
2392 | | - | |
2393 | | - | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
2394 | 2417 | | |
2395 | 2418 | | |
2396 | 2419 | | |
| |||
2399 | 2422 | | |
2400 | 2423 | | |
2401 | 2424 | | |
2402 | | - | |
2403 | | - | |
2404 | | - | |
2405 | | - | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
2406 | 2464 | | |
2407 | 2465 | | |
2408 | 2466 | | |
| |||
2591 | 2649 | | |
2592 | 2650 | | |
2593 | 2651 | | |
2594 | | - | |
2595 | | - | |
2596 | | - | |
2597 | | - | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
2598 | 2695 | | |
2599 | 2696 | | |
2600 | 2697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
436 | 434 | | |
437 | 435 | | |
438 | 436 | | |
| |||
442 | 440 | | |
443 | 441 | | |
444 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
445 | 455 | | |
446 | 456 | | |
447 | 457 | | |
| |||
458 | 468 | | |
459 | 469 | | |
460 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
461 | 481 | | |
462 | 482 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2384 | 2384 | | |
2385 | 2385 | | |
2386 | 2386 | | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
0 commit comments