question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cosmosdb mongodb collection update cannot set default TTL to -1

See original GitHub issue

Describe the bug

When attempting to enable TTL on cosmosdb mongo collection with no default, TTL is disabled instead.

To Reproduce:

Run the following command on an existing cosmosdb mongodb collection:

az cosmosdb mongodb collection update --account-name {} --resource-group {} --database-name {} --name {} --idx "[{\"key\": {\"keys\": [\"_ts\"]},\"options\": {\"expireAfterSeconds\": -1}}]"

When inspecting the result in mongo shell, the result looks like this:

        {
                "v" : 1,
                "key" : {
                        "_ts" : 1
                },
                "name" : "_ts_1",
                "ns" : "db.collection"
        }

Expected Behavior

The command should set default TTL to -1

        {
                "expireAfterSeconds" : -1,
                "v" : 1,
                "key" : {
                        "_ts" : 1
                },
                "name" : "_ts_1",
                "ns" : "db.collection"
        }

Environment Summary

Windows-10-10.0.17763-SP0
Python 3.6.6
Installer: MSI

azure-cli 2.5.0

Additional Context

Note that setting default TTL to -1 works fine if I use the deprecated command az cosmosdb collection update --name {} --resource-group-name {} --db-name {} --collection-name {} --default-ttl -1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shurdcommented, Apr 29, 2020

Hi @nohajc, I am looking into this issue. I will update once I finish my investigation

0reactions
MehaKaushikcommented, Sep 23, 2020

Since we do not have a timeline for this ask in the near future and we tracking it internally, I am closing this issue from github.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MongoDB per-document TTL feature in Azure Cosmos DB
Two modes are supported: setting a default TTL value on the whole collection, and setting individual TTL values for each document. The logic ......
Read more >
Azure Cosmos DB Set collection TTL as - on (No Default) via ...
DefaultTTL for the collection. If missing (or set to null), documents are not deleted automatically. If present and the value is set to...
Read more >
TTL Indexes — MongoDB Manual
TTL indexes are special single-field indexes that MongoDB can use to automatically remove documents from a collection after a certain amount of time...
Read more >
azurerm_cosmosdb_account | Resources | hashicorp/azurerm
Defaults to FirstPartyIdentity . kind - (Optional) Specifies the Kind of CosmosDB to create - possible values are GlobalDocumentDB , MongoDB and ...
Read more >
connect-mongo - npm
By default, connect-mongo uses MongoDB's TTL collection feature (2.2+) to have mongod automatically remove expired sessions. But you can change ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found