Repository navigation
fix(engine): refuse an UpdateTimeToLive that names another attribute while TTL is enabled - #1324
LeeroyHannigan wants to merge 1 commit into
Conversation
…while TTL is enabled With TTL ENABLED on `ttl`, DynamoDB refuses an UpdateTimeToLive that names another attribute, in the enable and in the disable form. The answer is 400 ValidationException "TimeToLive is active on a different AttributeName: current AttributeName is ttl" (measured 2026-11-21 in us-east-1). The comparison is byte-exact: `TTL` and `ttl ` get the same answer. ExtendDB answered the enable form with "TimeToLive is already enabled". It served the disable form with 200 on SQLite, PostgreSQL and MongoDB, which disabled TTL. On Cassandra the disable is conditional on the stored attribute. There it got ResourceInUseException "Table <name> is not in ACTIVE state" and TTL stayed enabled (read from the code, not run). check_ttl_transition now compares the stored attribute name with the request's while TTL is ENABLED, ahead of the "already enabled" check. The message carries the stored name. The ENABLING and DISABLING refusal keeps its answer. So do the "already enabled" answer for the stored name, the "already disabled" answer, and the answers for an ENABLED table with no stored name. A client that disables TTL with another attribute name now gets 400, and TTL stays enabled. The upgrade manual has a v1.1.0 entry for it. The transition_gate unit test is a data table of 16 rows. Nine are the measured rows. One is the disable with the stored name, which ExtendDB serves at once (the documented cooldown difference). The other six are the ENABLING, DISABLING and no-stored-name rows, which keep their answers. A wire test in tests/test_ttl.py sends the four refused shapes and the "already enabled" shape, each to a table enabled on `ttl`. It checks the status, the error code, the message, and that TTL stays enabled on `ttl`. Closes #609
demohan
left a comment
There was a problem hiding this comment.
UpdateTimeToLive refuses another attribute while TTL is enabled, as the service does, at 71f0a9b. In us-east-1, with TTL enabled on ttl, {true, expires}, {false, other}, TTL in both forms (the match is byte-exact) and "ttl " or "a b" in both forms get TimeToLive is active on a different AttributeName: current AttributeName is ttl, and {true, ttl} gets TimeToLive is already enabled; the length checks come first, then this check, then the one-hour rule, and on an UPDATING table the service answers the same. This head on SQLite and PostgreSQL matches every row but the one-hour rule and the name character set, both documented differences, and main served {false, other} with 200 and disabled TTL. After three refused requests the sweep still deleted the expired item on ttl (within 20 s on SQLite, 50 s on PostgreSQL) and kept items on other attributes, where main disabled TTL and deleted nothing in 200 s. Six mutations fail transition_gate, the wire test passes 16 of 16 on both backends and fails 4 of the 5 new rows on main, fmt and the 1.91.1 check are clean, and CI passes, the Cassandra and MongoDB shards included.
The upgrade manual conflicts with main at 222d80a; with both entries kept, the merged tree passes fmt, both clippy commands, the 1.94.0 check, the release build and the unit tests. v1.1.0 was tagged there without this change, and a 1.1.0 server still serves {false, other} and disables TTL, so the entry's place and wording need to move (below).
I will approve once main is merged and the upgrade entry sits under the next release.
| interprets existing data or configuration. Review these before upgrading a live | ||
| deployment, even when no catalog migration is required. | ||
|
|
||
| ### v1.1.0: UpdateTimeToLive refuses a request that names an attribute other than the enabled one |
There was a problem hiding this comment.
This is headed v1.1.0 and says "1.0.0 answered" and "served as in 1.0.0", but v1.1.0 was tagged at 222d80a on 2026-11-27 without this commit, and main's binaries there serve {Enabled: false, AttributeName: other} with 200 and disable TTL on SQLite and PostgreSQL. Moving the entry under the next release and saying 1.1.0 where it says 1.0.0 would hold.
What
check_ttl_transitionincrates/engine/src/ttl.rscompares the stored TTL attribute name with the request's while TTL isENABLED, in the enable and in the disable form. The comparison runs ahead of the "already enabled" check. A request that names another attribute gets 400ValidationExceptionTimeToLive is active on a different AttributeName: current AttributeName is <stored name>. The comparison is byte-exact.The
ENABLINGandDISABLINGrefusal keeps its answer. So do the "already enabled" answer for the stored name, the "already disabled" answer, and the answers for anENABLEDtable with no stored name. A disable with the stored name is still served at once. DynamoDB answers it with its cooldown sentence inside the interval, whichdocs/differences-from-dynamodb.mdrecords as an intended difference.A client that disables TTL with another attribute name now gets 400, and TTL stays enabled.
docs/manuals/07-upgrade-manual.mdgets a v1.1.0 entry for it under Behavior Changes by Release.Before this change, ExtendDB answered the enable form with
TimeToLive is already enabled. It served the disable form with 200 on SQLite, PostgreSQL and MongoDB, which disabled TTL. On Cassandra the disable is a conditional write on the stored attribute, so it gotResourceInUseExceptionTable <name> is not in ACTIVE stateand TTL stayed enabled (read from the code, not run).Why
These are DynamoDB's answers for a table with TTL
ENABLEDonttl, measured in us-east-1 on 21 November 2026. Each request went out twice on each of two tables and got the same answer every time.UpdateTimeToLive{Enabled: true, AttributeName: expires}ValidationException:TimeToLive is active on a different AttributeName: current AttributeName is ttl{Enabled: false, AttributeName: other}{Enabled: true, AttributeName: TTL}and the disable form{Enabled: true, AttributeName: "ttl "}(trailing space) and the disable form{Enabled: true, AttributeName: ttl}ValidationException:TimeToLive is already enabled{Enabled: false, AttributeName: ttl}, inside the cooldown intervalValidationException:Time to live has been modified multiple times within a fixed intervalDescribeTimeToLiveafter each refused request reportedENABLEDonttl. On a table with TTLDISABLED,{Enabled: false, AttributeName: other}gotTimeToLive is already disabled.Closes #609
Testing done
cargo test -p extenddb-engine --lib ttl::: 7 passed.transition_gateis a data table of 16 rows (state, stored name, request, answer). They are the measured rows, the disable with the stored name that ExtendDB serves at once, and theENABLING,DISABLINGand no-stored-name rows. Those last rows keep their answers.tests/test_ttl.py::TestUpdateTimeToLiveOnAnotherAttributesends the four refused shapes and the "already enabled" shape, each to its own table enabled onttl. Each row checks status 400, the error code, the full message, and thatDescribeTimeToLivestill reportsENABLEDonttl. Against DynamoDB: 5 passed. Against ExtendDB on SQLite built from this branch: 5 passed, and the 16 tests of the file passed. Against a build of main: the two enable rows fail on the message and the two disable rows get a 200. The "already enabled" row passes there, as its answer does not change.cargo +1.97.0 fmt --all -- --check, both clippy commands of.github/workflows/clippy.ymlwith-D warningsonextenddb-engine, andcargo +1.91.1 check -p extenddb-engineare clean.Line counts: production +40 -30, tests +116 -25, docs +6.
Other open PRs:
handle_update_time_to_liveand its ownErrorMessageKeyentries. The merge with it conflicts in one hunk, theuse extenddb_core::typeslist at the top ofttl.rs, where both sides add names. The rest merges on its own.storage_to_dynamoin the same file. The merge with it is clean.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.