Fix stale serializer cache IDs after deletion - #9390
Conversation
FindingsThe reviewed change is a single commit touching Low -
|
|
Thanks for the detailed review. Addressed in 6f36882: ObjectSerializerDisk.delete() is now idempotent for missing files per the base contract; forward-cache cleanup and on_deleted callbacks run in a finally block so cache state remains consistent when underlying deletion raises; regression coverage now includes a missing backing file, FIFO order after deleting a middle entry, and deletion of an already-evicted entry. The original regression test also reuses the existing fwd_cache fixture. Local verification: 20 object serializer tests passed, Ruff lint and format checks passed, and git diff --check passed. |
|
Note: Accepting this PR should result in closing PR #9371, and vice versa. This PR seems more robust to me. |
|
@longligooo Also adding my notes on this PR here:
Attaching a standalone test that illustrates this that could be integrated with the regular tests: test_pr9390_concurrency.py |
…e-deletion # Conflicts: # invokeai/app/services/object_serializer/object_serializer_forward_cache.py
|
Thanks for the deterministic reproducer. Addressed in 2e9a9a1, with current main merged in ebbdf67. The forward cache now uses a single RLock to serialize complete transitions across both _cache and _cache_ids, including the queue drain and rebuild performed by concurrent deletes. Reentrancy is required because the transition methods call cache helpers that share the same lock, and deletion callbacks remain outside the critical section. I added a deterministic regression test that pauses the first delete after draining the queue, starts a second delete, verifies that it cannot complete until the first transition is released, then saves two new entries and checks that no stale eviction ID or KeyError remains. Local verification after resolving the main-branch conflict: 31 focused serializer/cache tests passed; full-repository Ruff 0.11.2 lint passed; full-repository Ruff format check passed (1169 files); and git diff origin/main --check passed. |
Findings1. Medium-High --
|
Summary
Related Issues / Discussions
Closes #9370
QA Instructions
Run the focused regression test:
Run the configured lint check on the changed files:
Merge Plan
No special merge steps are required.
Checklist
What's Newcopy (if doing a release after this PR) (not applicable)