Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-36397

Embedded Server SDK Should Return Error When TTL Index Creation is Attempted

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.2, 4.1.2
    • Affects Version/s: None
    • Component/s: Storage
    • None
    • Fully Compatible
    • v4.0
    • Platforms 2018-08-13

      The Embedded Server doesn't support TTL indexes today – because there are no background threads in the Embedded Server, and there's a dedicated background thread used for expiring TTL indexes – so we should return an error when a user tries to create them. We don't seem to be doing that today though:

      From the client side:

      test@mongolord> version()
      test@mongolord> db.version()
      test@mongolord> db.serverStatus().storageEngine
      	"name" : "mobile",
      	"supportsCommittedReads" : false,
      	"supportsSnapshotReadConcern" : false,
      	"readOnly" : false,
      	"persistent" : true
      test@mongolord> use test;
      switched to db test
      test@mongolord> db.ttltest.insertOne( {"name":"Matt Lord", "age":42, "inserted":new Date()} );
      	"acknowledged" : true,
      	"insertedId" : ObjectId("5b63166b9904d20a99a3faba")
      test@mongolord> db.ttltest.find()
      { "_id" : ObjectId("5b63166b9904d20a99a3faba"), "name" : "Matt Lord", "age" : 42, "inserted" : ISODate("2018-08-02T14:34:19.480Z") }
      test@mongolord> db.ttltest.createIndex( {"inserted":1}, {expireAfterSeconds:3} );
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      test@mongolord> sleep(15000);
      test@mongolord> db.ttltest.find();
      { "_id" : ObjectId("5b63166b9904d20a99a3faba"), "name" : "Matt Lord", "age" : 42, "inserted" : ISODate("2018-08-02T14:34:19.480Z") }

      From the Server side:

      mongolord:mongo matt$ ./mongoed --dbpath /tmp/
      2018-08-02T10:32:48.208-0400 I -        [main] MongoDB embedded standalone application, for testing purposes only
      2018-08-02T10:32:48.258-0400 I CONTROL  [initandlisten] MongoDB starting : pid=32931 port=27017 dbpath=/tmp/ 64-bit
      2018-08-02T10:32:48.284-0400 I STORAGE  [initandlisten] createCollection: admin.system.version with provided UUID: c8856c07-86c3-4c33-ab0b-6ef6990450df
      2018-08-02T10:32:48.294-0400 W ASIO     [initandlisten] No TransportLayer configured during NetworkInterface startup
      2018-08-02T10:32:48.296-0400 I COMMAND  [initandlisten] setting featureCompatibilityVersion to 4.2
      2018-08-02T10:32:48.301-0400 I NETWORK  [initandlisten] waiting for connections on port 27017
      2018-08-02T10:32:56.420-0400 I NETWORK  [listener] connection accepted from #1 (1 connection now open)
      2018-08-02T10:32:56.423-0400 I NETWORK  [conn1] received client metadata from conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.1.1-189-g114b1e828e" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "17.7.0" } }
      2018-08-02T10:34:19.492-0400 I STORAGE  [conn1] createCollection: test.ttltest with generated UUID: 67ff252c-4685-4fbb-b438-4e49c92c5ca0
      2018-08-02T10:34:19.510-0400 I INDEX    [conn1] build index on: test.ttltest properties: { v: 2, key: { inserted: 1.0 }, name: "inserted_1", ns: "test.ttltest", expireAfterSeconds: 3.0 }
      2018-08-02T10:34:19.510-0400 I INDEX    [conn1] 	 building index using bulk method; build may temporarily use up to 500 megabytes of RAM
      2018-08-02T10:34:19.511-0400 I INDEX    [conn1] build index done.  scanned 1 total records. 0 secs

      We should return an error to the client immediately that TTL indexes are not supported, like we currently do for capped collections.

            Unassigned Unassigned
            matt.lord Matt Lord (Inactive)
            0 Vote for this issue
            8 Start watching this issue