Repository navigation
fix(idempotency): stop daylight saving changes from shifting record expiry - #8915
Draft
cleissonom wants to merge 2 commits into
Draft
cleissonom wants to merge 2 commits into
cleissonom wants to merge 2 commits into
Conversation
|
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 #8910
Summary
Changes
BasePersistenceLayer._get_expiry_timestampaddsexpires_after_secondstodatetime.now(), a naive local time, and then converts the result to a Unix timestamp. When the UTC offset changes inside that window, the deadline moves by the size of the change: later when daylight saving time ends, earlier when it starts. In the hour that repeats after the clocks go back, the sum also losesfold, so a deadline computed during that hour that also falls inside it is stored an hour early.save_inprogresscomputes the in-progress expiry the same way.Both now start from
datetime.now(timezone.utc), so the period is added in elapsed seconds. The stored values are still Unix timestamps.User experience
With
TZ=America/New_Yorkandexpires_after_seconds=7200:Values only change in time zones with daylight saving, around a change. In UTC, Lambda's default, they are the same as in 3.41.0. This changes behaviour as a bug fix under ADR 0006: the old values contradicted
expires_after_seconds, which the docs define in seconds.Verification
I used an AI coding assistant to write the change, the test and this description. It ran the checks below; I'll repeat them myself before marking this ready for review.
test_idempotent_function_expiry_across_daylight_saving_changecalls a function decorated withidempotent_function, with the local cache, then repeats the call 7,200 and 7,201 seconds later and checks the saved in-progress expiry. It covers both changes and the repeated hour in New York, with UTC as the control. The timezone is set throughTZandtime.tzset(), andnow()is controlled by replacingdatetime.datetimewith a subclass.On macOS arm64 with CPython 3.14.10 and locked dependencies,
uv run --locked pytest --disable-socket -q "tests/functional/idempotency/_boto3/test_idempotency.py::test_idempotent_function_expiry_across_daylight_saving_change"gave 3 failed, 1 passed ondevelop(0bbc252e) with only the test added, and 4 passed with the change.make prwithoutlint-docs, which needs Docker (no Markdown changed): ruff, mypy, bandit, xenon and pre-commit pass, with 4,361 passed and 73 skipped. Two timing-based tests,test_data_masking_encrypt_with_json_blobandtest_tracer_init, failed in some runs on import-time limits, ondeveloptoo, while the machine was under heavy load.TZ=America/New_Yorkas withTZ=UTC.Nothing has been run against DynamoDB or Redis yet. I'll check the values written to a real DynamoDB table before marking this ready. Until a maintainer triages #8910, this stays a draft.
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.