Skip to content

fix(engine): refuse an UpdateTimeToLive that names another attribute while TTL is enabled - #1324

Open
LeeroyHannigan wants to merge 1 commit into
mainfrom
fix/609-ttl-different-attribute
Open

LeeroyHannigan wants to merge 1 commit into
mainfrom
fix/609-ttl-different-attribute

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

What

check_ttl_transition in crates/engine/src/ttl.rs compares the stored TTL attribute name with the request's while TTL is ENABLED, in the enable and in the disable form. The comparison runs ahead of the "already enabled" check. A request that names another attribute gets 400 ValidationException TimeToLive is active on a different AttributeName: current AttributeName is <stored name>. The comparison is byte-exact.

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 disable with the stored name is still served at once. DynamoDB answers it with its cooldown sentence inside the interval, which docs/differences-from-dynamodb.md records 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.md gets 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 got ResourceInUseException Table <name> is not in ACTIVE state and TTL stayed enabled (read from the code, not run).

Why

These are DynamoDB's answers for a table with TTL ENABLED on ttl, 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 DynamoDB
{Enabled: true, AttributeName: expires} ValidationException: TimeToLive is active on a different AttributeName: current AttributeName is ttl
{Enabled: false, AttributeName: other} the same text
{Enabled: true, AttributeName: TTL} and the disable form the same text
{Enabled: true, AttributeName: "ttl "} (trailing space) and the disable form the same text
{Enabled: true, AttributeName: ttl} ValidationException: TimeToLive is already enabled
{Enabled: false, AttributeName: ttl}, inside the cooldown interval ValidationException: Time to live has been modified multiple times within a fixed interval

DescribeTimeToLive after each refused request reported ENABLED on ttl. On a table with TTL DISABLED, {Enabled: false, AttributeName: other} got TimeToLive is already disabled.

Closes #609

Testing done

  • cargo test -p extenddb-engine --lib ttl::: 7 passed. transition_gate is 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 the ENABLING, DISABLING and no-stored-name rows. Those last rows keep their answers.
  • tests/test_ttl.py::TestUpdateTimeToLiveOnAnotherAttribute sends the four refused shapes and the "already enabled" shape, each to its own table enabled on ttl. Each row checks status 400, the error code, the full message, and that DescribeTimeToLive still reports ENABLED on ttl. 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.
  • Five changes to the fix each fail the unit test and the wire test. Four of them: the comparison removed, a case-insensitive comparison, the comparison after the "already enabled" arm, and the stored name dropped from the message. The fifth: the comparison in the enable form only.
  • cargo +1.97.0 fmt --all -- --check, both clippy commands of .github/workflows/clippy.yml with -D warnings on extenddb-engine, and cargo +1.91.1 check -p extenddb-engine are clean.

Line counts: production +40 -30, tests +116 -25, docs +6.

Other open PRs:

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, 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.

…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 demohan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UpdateTimeToLive on a table with TTL active on another attribute answers differently from DynamoDB, in the enable and the disable form

2 participants