Repository navigation
Conversation
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
|
Contributor
|
Thanks for the PR and for filling in the verification section, that helps. Heads up that the review may take a few days: this goes into 3.41.0 and I review every PR against a real service before approving, one at a time. No need to rebase or ping in the meantime, I'll come back here. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number: closes #8727
Summary
Fix a race condition in the Redis idempotency persistence layer where an existing record expires between a failed
SET NXoperation and the subsequentGET.Previously, this caused an
IdempotencyItemNotFoundErrorto escape and be wrapped as anIdempotencyPersistenceLayerError, failing the Lambda invocation instead of retrying.Changes
IdempotencyItemNotFoundErrorwhen retrieving a record after a failed RedisSET NX.IdempotencyInconsistentStateErrorto signal the recoverable inconsistent state.User experience
Before: If an existing Redis idempotency record expired between
SET NXandGET, the invocation failed with a persistence-layer error.After: The Redis persistence layer raises
IdempotencyInconsistentStateError, allowing the existing retry mechanism to retry the operation. The invocation succeeds when the subsequent attempt acquires the lock successfully.Verification
Tests and checks run locally:
uv run --locked pytest tests/functional/idempotency/_redis/test_redis_layer.py -k inconsistent_state -v— 3 passed.uv run --locked pytest tests/functional/idempotency/_redis/test_redis_layer.py -q— 33 passed.uv run --locked ruff check aws_lambda_powertools/utilities/idempotency/base.py aws_lambda_powertools/utilities/idempotency/persistence/redis.py tests/functional/idempotency/_redis/test_redis_layer.py— passed.uv run --locked mypy aws_lambda_powertools/utilities/idempotency/base.py aws_lambda_powertools/utilities/idempotency/persistence/redis.py— passed.git diff --check— passed.The regression scenario was verified using a mocked Redis client. Real Redis service validation has not been performed.
This contribution was developed with AI assistance. I reviewed the changes and personally ran the tests and checks listed above.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.