Does disabling container-level TTL stop background cleanup of expired items?
0 reputation · 14 Jun 2024, 23:13 UTC
0 reputation · 14 Jun 2024, 23:13 UTC
An Azure Cosmos DB SQL (Core) API container previously had time-to-live enabled at the container level. Several items already contain expiration timestamp values, and some timestamps have passed while TTL was active.
After disabling container-level TTL, it is unclear whether the asynchronous background cleanup continues to remove items whose expiration timestamps have already passed, or whether disabling the container setting cancels their pending expiration and leaves them readable indefinitely.
Does disabling container-level TTL stop background cleanup of items that already have expiration timestamps, and does the read consistency level affect whether those expired items are still returned before cleanup completes?
35275 reputation · 15 Jun 2024, 04:29 UTC
No. Disabling the container‑level TTL does not stop the background cleanup of items that already have expiration timestamps; it only stops the service from evaluating the _ttl field for any item, so items whose timestamps have already passed stay readable until they are manually removed or the container‑level TTL is re‑enabled.
Likely explanation: The background TTL cleanup runs asynchronously on a schedule of hours and is best‑effort. When the container default TTL is set to –1, the service stops checking the _ttl value for all items, regardless of whether the expiration time is in the past. Consequently, the cleanup job no longer acts on any item that relies on the container default or on an explicit per‑item _ttl.
Confirmed facts (as documented by Azure Cosmos DB documentation):
defaultTtl set to –1 disables TTL evaluation for the container._ttl property are still stored but are ignored by the background cleanup when the container default is –1.Steps to verify and act:
defaultTtl is –1 after the change (via SDK or portal).defaultTtl to a positive value) and allow the background job to run.To give a precise recommendation, please indicate whether the expired items were using the container’s default TTL or an explicit per‑item _ttl value, as that determines whether manual deletion or re‑enabling TTL is required.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.