Skip to content

improve Patch utility: add idempotency #12919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented Jul 28, 2025

Motivation

While using the Patch utility, we realize we had to manually check if patch.is_applied before applying it again because it did not check itself if it was already applied.

This PR adds this check internally to avoid applying the patch twice.

It also adds a test for it, and some more patches for some issues we realized and should keep track of.

I've added a single lock for the Patch class as we're mutating the global class variable applied_patches, and it feels like once we start adding more checks for multiple patches mutating the same function, this kind of global lock could be useful.

Linearizing the Patching mechanism over one single lock sounds a bit safer than having a single lock per Patch, and will probably end up using a little bit less memory.

Changes

  • add an internal check for Patch.apply and Patch.undo to verify if the patch was already applied, locked with a single lock for the Patch class
  • add xfailed tests for the Patch class over multiple patching of the same function

@bentsku bentsku added this to the 4.8 milestone Jul 28, 2025
@bentsku bentsku self-assigned this Jul 28, 2025
@bentsku bentsku added the semver: patch Non-breaking changes which can be included in patch releases label Jul 28, 2025
Copy link

github-actions bot commented Jul 28, 2025

Test Results - Preflight, Unit

21 995 tests  +4   20 259 ✅ +2   6m 18s ⏱️ -31s
     1 suites ±0    1 736 💤 +2 
     1 files   ±0        0 ❌ ±0 

Results for commit ada4ee6. ± Comparison against base commit 0be7798.

♻️ This comment has been updated with latest results.

Copy link

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 10s ⏱️ -5s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit ada4ee6. ± Comparison against base commit 0be7798.

Copy link

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 20m 28s ⏱️
4 841 tests 4 361 ✅ 480 💤 0 ❌
4 847 runs  4 361 ✅ 486 💤 0 ❌

Results for commit ada4ee6.

Copy link

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 44m 14s ⏱️ - 4m 7s
4 940 tests ±0  4 169 ✅ ±0  771 💤 ±0  0 ❌ ±0 
4 942 runs  ±0  4 169 ✅ ±0  773 💤 ±0  0 ❌ ±0 

Results for commit ada4ee6. ± Comparison against base commit 0be7798.

@bentsku bentsku requested a review from thrau July 29, 2025 09:54
@bentsku bentsku marked this pull request as ready for review July 29, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant